public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/gdb] gdb-17.2-rebase-f44: Merge #25 `tests/gdb-testsuite-sanity: add testcase`
@ 2026-06-28 0:00 Kevin Buettner
0 siblings, 0 replies; only message in thread
From: Kevin Buettner @ 2026-06-28 0:00 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/gdb
Branch : gdb-17.2-rebase-f44
Commit : e66c7e71e79e473ffc278879bd042ebdf2123aad
Author : Kevin Buettner <kevinb@redhat.com>
Date : 2022-01-17T16:44:50+00:00
Stats : +3729/-7625 in 60 file(s)
URL : https://src.fedoraproject.org/rpms/gdb/c/e66c7e71e79e473ffc278879bd042ebdf2123aad?branch=gdb-17.2-rebase-f44
Log:
Merge #25 `tests/gdb-testsuite-sanity: add testcase`
---
diff --git a/tests/gdb-testsuite-sanity/Makefile b/tests/gdb-testsuite-sanity/Makefile
new file mode 100644
index 0000000..c74a922
--- /dev/null
+++ b/tests/gdb-testsuite-sanity/Makefile
@@ -0,0 +1,68 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Makefile of /tools/gdb/Sanity/gdb-testsuite-sanity
+# Description: gdb testing by upstream testsuite
+# Author: Michal Kolar <mkolar@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2021 Red Hat, Inc.
+#
+# This program is free software: you can 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, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+export TEST=/tools/gdb/Sanity/gdb-testsuite-sanity
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE ref
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ./runtest.sh
+
+build: $(BUILT_FILES)
+ test -x runtest.sh || chmod a+x runtest.sh
+
+.SILENT: ref_file
+ref_file: ./ref/gen.sh
+ test -x ./ref/gen.sh || chmod a+x ./ref/gen.sh
+ ./ref/gen.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Michal Kolar <mkolar@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: gdb testing by upstream testsuite" >> $(METADATA)
+ @echo "Type: Sanity" >> $(METADATA)
+ @echo "TestTime: 1h" >> $(METADATA)
+ @echo "RunFor: gdb" >> $(METADATA)
+ @echo "Requires: gdb rpm-build yum-utils dejagnu make gcc gcc-gfortran glibc" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv2+" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+ @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5 -RHEL6 -RHEL7" >> $(METADATA)
+
+ rhts-lint $(METADATA)
diff --git a/tests/gdb-testsuite-sanity/PURPOSE b/tests/gdb-testsuite-sanity/PURPOSE
new file mode 100644
index 0000000..83d868f
--- /dev/null
+++ b/tests/gdb-testsuite-sanity/PURPOSE
@@ -0,0 +1,30 @@
+PURPOSE of /tools/gdb/Sanity/gdb-testsuite-sanity
+Description: gdb testing by upstream testsuite
+Author: Michal Kolar <mkolar@redhat.com>
+
+By default, testsuite is executed with default options for the package that
+corresponds to the gdb command by newly created ordinary user. Before
+executing, the testsuite is reduced by the appropriate reference file that
+defines the allowed test range.
+
+Executing can be modified by these variables:
+ * BUILD_USER -- user which will be used for building and testing gdb
+ * PACKAGE -- explicitly defines which rpm package should be tested
+ * RUNTESTFLAGS -- variable which will be forwarded to 'make check' command
+ and can be used to reduce the range of testing
+ * TESTS_COUNT_MIN -- minimum number of cases that should be tested (does not
+ affect the triggering of testcases, it only sets the
+ value of the reference comparator)
+
+Example:
+ $ BUILD_USER=root \
+ PACKAGE=gdb \
+ RUNTESTFLAGS='GDB=/usr/bin/gdb gdb.base/break*.exp' \
+ TESTS_COUNT_MIN=32 make run
+
+Reference files instructions:
+ * path of reference file for current package, distribution and architecture
+ can be generated by:
+ $ make ref_file
+ or directly by:
+ $ ./ref/gen.sh
diff --git a/tests/gdb-testsuite-sanity/main.fmf b/tests/gdb-testsuite-sanity/main.fmf
new file mode 100644
index 0000000..32f0351
--- /dev/null
+++ b/tests/gdb-testsuite-sanity/main.fmf
@@ -0,0 +1,45 @@
+summary: gdb testing by upstream testsuite
+description: |
+ By default, testsuite is executed with default options for the package that
+ corresponds to the gdb command by newly created ordinary user. Before
+ executing, the testsuite is reduced by the appropriate reference file that
+ defines the allowed test range.
+
+ Executing can be modified by these variables:
+ * BUILD_USER -- user which will be used for building and testing gdb
+ * PACKAGE -- explicitly defines which rpm package should be tested
+ * RUNTESTFLAGS -- variable which will be forwarded to 'make check' command
+ and can be used to reduce the range of testing
+ * TESTS_COUNT_MIN -- minimum number of cases that should be tested (does not
+ affect the triggering of testcases, it only sets the
+ value of the reference comparator)
+
+ Example:
+ $ BUILD_USER=root \
+ PACKAGE=gdb \
+ RUNTESTFLAGS='GDB=/usr/bin/gdb gdb.base/break*.exp' \
+ TESTS_COUNT_MIN=32 make run
+
+ Reference files instructions:
+ * path of reference file for current package, distribution and architecture
+ can be generated by:
+ $ make ref_file
+ or directly by:
+ $ ./ref/gen.sh
+contact: Michal Kolar <mkolar@redhat.com>
+component:
+- gdb
+test: ./runtest.sh
+framework: beakerlib
+recommend:
+- gdb
+- rpm-build
+- yum-utils
+- dejagnu
+- make
+- gcc
+- gcc-gfortran
+- glibc
+duration: 1h
+extra-summary: /tools/gdb/Sanity/gdb-testsuite-sanity
+extra-task: /tools/gdb/Sanity/gdb-testsuite-sanity
diff --git a/tests/gdb-testsuite-sanity/ref/default b/tests/gdb-testsuite-sanity/ref/default
new file mode 100644
index 0000000..07860a5
--- /dev/null
+++ b/tests/gdb-testsuite-sanity/ref/default
@@ -0,0 +1,431 @@
+gdb.base/advance-until-multiple-locations.exp
+gdb.base/alias.exp
+gdb.base/align-c.exp
+gdb.base/annota-input-while-running.exp
+gdb.base/anon.exp
+gdb.base/args.exp
+gdb.base/arrayidx.exp
+gdb.base/attach-non-pgrp-leader.exp
+gdb.base/attach-pie-noexec.exp
+gdb.base/attach-twice.exp
+gdb.base/attach-wait-input.exp
+gdb.base/auto-load.exp
+gdb.base/bang.exp
+gdb.base/batch-exit-status.exp
+gdb.base/bfp-test.exp
+gdb.base/bg-execution-repeat.exp
+gdb.base/bitfields2.exp
+gdb.base/bitfields.exp
+gdb.base/bitops.exp
+gdb.base/bp-cmds-execution-x-script.exp
+gdb.base/branch-to-self.exp
+gdb.base/break-always.exp
+gdb.base/break-caller-line.exp
+gdb.base/break-include.exp
+gdb.base/break-inline.exp
+gdb.base/break-main-file-remove-fail.exp
+gdb.base/break-on-linker-gcd-function.exp
+gdb.base/breakpoint-shadow.exp
+gdb.base/break-probes.exp
+gdb.base/cached-source-file.exp
+gdb.base/callexit.exp
+gdb.base/call-strs.exp
+gdb.base/catch-follow-exec.exp
+gdb.base/catch-gdb-caused-signals.exp
+gdb.base/catch-signal-fork.exp
+gdb.base/catch-signal-siginfo-cond.exp
+gdb.base/check-psymtab.exp
+gdb.base/c-linkage-name.exp
+gdb.base/code_elim.exp
+gdb.base/command-line-input.exp
+gdb.base/compare-sections.exp
+gdb.base/complex.exp
+gdb.base/comprdebug.exp
+gdb.base/consecutive-step-over.exp
+gdb.base/continue-all-already-running.exp
+gdb.base/coredump-filter.exp
+gdb.base/corefile2.exp
+gdb.base/corefile-buildid.exp
+gdb.base/cursal.exp
+gdb.base/datalib.exp
+gdb.base/dcache-line-read-error.exp
+gdb.base/default-args.exp
+gdb.base/define.exp
+gdb.base/disabled-location.exp
+gdb.base/disasm-end-cu.exp
+gdb.base/disasm-optim.exp
+gdb.base/double-prompt-target-event-error.exp
+gdb.base/dprintf-detach.exp
+gdb.base/dprintf-next.exp
+gdb.base/dprintf-non-stop.exp
+gdb.base/dprintf-pending.exp
+gdb.base/dso2dso.exp
+gdb.base/dump.exp
+gdb.base/dup-sect.exp
+gdb.base/echo.exp
+gdb.base/empty_exe.exp
+gdb.base/endian.exp
+gdb.base/endianity.exp
+gdb.base/enumval.exp
+gdb.base/environ.exp
+gdb.base/eu-strip-infcall.exp
+gdb.base/eval.exp
+gdb.base/examine-backward.exp
+gdb.base/exec-invalid-sysroot.exp
+gdb.base/execution-termios.exp
+gdb.base/exe-lock.exp
+gdb.base/exitsignal.exp
+gdb.base/expand-psymtabs.exp
+gdb.base/filesym.exp
+gdb.base/find-unmapped.exp
+gdb.base/fixsection.exp
+gdb.base/flexible-array-member.exp
+gdb.base/float.exp
+gdb.base/floatn.exp
+gdb.base/focus-cmd-prev.exp
+gdb.base/foll-exec.exp
+gdb.base/foll-exec-mode.exp
+gdb.base/fortran-sym-case.exp
+gdb.base/frame-selection.exp
+gdb.base/freebpcmd.exp
+gdb.base/fullname.exp
+gdb.base/fullpath-expand.exp
+gdb.base/func-ptr.exp
+gdb.base/gcore-buffer-overflow.exp
+gdb.base/gcore-relro.exp
+gdb.base/gdb1056.exp
+gdb.base/gdb1090.exp
+gdb.base/gdb11530.exp
+gdb.base/gdb11531.exp
+gdb.base/gdb1250.exp
+gdb.base/gdb1555.exp
+gdb.base/gdb1821.exp
+gdb.base/gdbhistsize-history.exp
+gdb.base/gdb-sigterm-2.exp
+gdb.base/hashline2.exp
+gdb.base/hashline3.exp
+gdb.base/hbreak.exp
+gdb.base/hbreak-unmapped.exp
+gdb.base/help.exp
+gdb.base/history-duplicates.exp
+gdb.base/hook-stop.exp
+gdb.base/huge.exp
+gdb.base/hw-sw-break-same-address.exp
+gdb.base/ifelse.exp
+gdb.base/index-cache.exp
+gdb.base/infcall-input.exp
+gdb.base/infcall-nested-structs-c++.exp
+gdb.base/infcall-nested-structs-c.exp
+gdb.base/infnan.exp
+gdb.base/infoline.exp
+gdb.base/info-locals-unused-static-var.exp
+gdb.base/info_minsym.exp
+gdb.base/info-proc.exp
+gdb.base/info-program.exp
+gdb.base/info_qt.exp
+gdb.base/info-shared.exp
+gdb.base/info_sources.exp
+gdb.base/info-target.exp
+gdb.base/info-types-c++.exp
+gdb.base/info-types-c.exp
+gdb.base/info-var.exp
+gdb.base/interact.exp
+gdb.base/interrupt-daemon-attach.exp
+gdb.base/interrupt-daemon.exp
+gdb.base/interrupt-noterm.exp
+gdb.base/jit-attach-pie.exp
+gdb.base/jit-reader-exec.exp
+gdb.base/jit-reader-simple.exp
+gdb.base/jump.exp
+gdb.base/kill-detach-inferiors-cmd.exp
+gdb.base/killed-outside.exp
+gdb.base/label.exp
+gdb.base/label-without-address.exp
+gdb.base/largecore-last-address-lock.exp
+gdb.base/lineinc.exp
+gdb.base/lineno-makeup.exp
+gdb.base/linespecs.exp
+gdb.base/line-symtabs.exp
+gdb.base/list-ambiguous.exp
+gdb.base/list-missing-source.exp
+gdb.base/logical.exp
+gdb.base/longest-types.exp
+gdb.base/longjmp.exp
+gdb.base/long_long.exp
+gdb.base/maint-expand-symbols-header-file.exp
+gdb.base/maint-target-async-off.exp
+gdb.base/many-completions.exp
+gdb.base/many-headers.exp
+gdb.base/max-depth-c++.exp
+gdb.base/max-depth-c.exp
+gdb.base/max-value-size.exp
+gdb.base/memattr.exp
+gdb.base/mips_pro.exp
+gdb.base/move-dir.exp
+gdb.base/msym-lang.exp
+gdb.base/nested-addr.exp
+gdb.base/nextoverexit.exp
+gdb.base/nodebug.exp
+gdb.base/noreturn-finish.exp
+gdb.base/noreturn-return.exp
+gdb.base/offsets.exp
+gdb.base/osabi.exp
+gdb.base/overlays.exp
+gdb.base/page.exp
+gdb.base/paginate-after-ctrl-c-running.exp
+gdb.base/paginate-bg-execution.exp
+gdb.base/paginate-execution-startup.exp
+gdb.base/paginate-inferior-exit.exp
+gdb.base/pc-fp.exp
+gdb.base/permissions.exp
+gdb.base/pr10179.exp
+gdb.base/pretty-print.exp
+gdb.base/prologue.exp
+gdb.base/prologue-include.exp
+gdb.base/psym-external-decl.exp
+gdb.base/psymtab.exp
+gdb.base/ptr-typedef.exp
+gdb.base/quit.exp
+gdb.base/quit-live.exp
+gdb.base/randomize.exp
+gdb.base/random-signal.exp
+gdb.base/readline-overflow.exp
+gdb.base/reggroups.exp
+gdb.base/remote-exec-file.exp
+gdb.base/remote.exp
+gdb.base/remotetimeout.exp
+gdb.base/reread-readsym.exp
+gdb.base/return.exp
+gdb.base/return-nodebug.exp
+gdb.base/run-after-attach.exp
+gdb.base/save-bp.exp
+gdb.base/sect-cmd.exp
+gdb.base/sep.exp
+gdb.base/sepsymtab.exp
+gdb.base/server-del-break.exp
+gdb.base/set-inferior-tty.exp
+gdb.base/set-lang-auto.exp
+gdb.base/set-noassign.exp
+gdb.base/set-solib-absolute-prefix.exp
+gdb.base/shell.exp
+gdb.base/shreloc.exp
+gdb.base/sigall.exp
+gdb.base/sigchld.exp
+gdb.base/signest.exp
+gdb.base/sigrepeat.exp
+gdb.base/skip-inline.exp
+gdb.base/solib-disc.exp
+gdb.base/solib-nodir.exp
+gdb.base/solib-probes-nosharedlibrary.exp
+gdb.base/solib-vanish.exp
+gdb.base/source-execution.exp
+gdb.base/source.exp
+gdb.base/sss-bp-on-user-bp.exp
+gdb.base/stale-infcall.exp
+gdb.base/start.exp
+gdb.base/startup-with-shell.exp
+gdb.base/statistics.exp
+gdb.base/step-resume-infcall.exp
+gdb.base/step-sw-breakpoint-adjust-pc.exp
+gdb.base/step-symless.exp
+gdb.base/step-test.exp
+gdb.base/structs2.exp
+gdb.base/structs3.exp
+gdb.base/style.exp
+gdb.base/style-logging.exp
+gdb.base/symbol-alias.exp
+gdb.base/sym-file.exp
+gdb.base/symfile-warn.exp
+gdb.base/symlink-sourcefile.exp
+gdb.base/symtab-search-order.exp
+gdb.base/tab-crash.exp
+gdb.base/term.exp
+gdb.base/testenv.exp
+gdb.base/trace-commands.exp
+gdb.base/tracefork-zombie.exp
+gdb.base/twice.exp
+gdb.base/type-opaque.exp
+gdb.base/until.exp
+gdb.base/value-double-free.exp
+gdb.base/vdso-warning.exp
+gdb.base/vla-ptr.exp
+gdb.base/warning.exp
+gdb.base/watch-cond-infcall.exp
+gdb.base/watch-non-mem.exp
+gdb.base/watchpoint-cond-gone.exp
+gdb.base/watchpoint-delete.exp
+gdb.base/watchpoint-during-step.exp
+gdb.base/watch-vfork.exp
+gdb.base/wchar.exp
+gdb.base/with.exp
+gdb.base/with-mf.exp
+gdb.cp/abstract-origin.exp
+gdb.cp/ambiguous.exp
+gdb.cp/anon-ns.exp
+gdb.cp/anon-struct.exp
+gdb.cp/anon-union.exp
+gdb.cp/arg-reference.exp
+gdb.cp/b146835.exp
+gdb.cp/baseenum.exp
+gdb.cp/bool.exp
+gdb.cp/breakpoint-locs.exp
+gdb.cp/bs15503.exp
+gdb.cp/call-c.exp
+gdb.cp/chained-calls.exp
+gdb.cp/class2.exp
+gdb.cp/cmpd-minsyms.exp
+gdb.cp/converts.exp
+gdb.cp/cpcompletion.exp
+gdb.cp/cpexprs-debug-types.exp
+gdb.cp/cplabel.exp
+gdb.cp/cpsizeof.exp
+gdb.cp/ctti.exp
+gdb.cp/debug-expr.exp
+gdb.cp/demangle.exp
+gdb.cp/derivation.exp
+gdb.cp/destrprint.exp
+gdb.cp/disasm-func-name.exp
+gdb.cp/dispcxx.exp
+gdb.cp/ena-dis-br-range.exp
+gdb.cp/enum-class.exp
+gdb.cp/exception.exp
+gdb.cp/exceptprint.exp
+gdb.cp/expand-psymtabs-cxx.exp
+gdb.cp/expand-sals.exp
+gdb.cp/extern-c.exp
+gdb.cp/formatted-ref.exp
+gdb.cp/fpointer.exp
+gdb.cp/gdb1355.exp
+gdb.cp/hang.exp
+gdb.cp/impl-this.exp
+gdb.cp/infcall-dlopen.exp
+gdb.cp/infcall-nodebug-c++-d0.exp
+gdb.cp/infcall-nodebug-c-d0.exp
+gdb.cp/infcall-nodebug-c++-d1.exp
+gdb.cp/infcall-nodebug-c-d1.exp
+gdb.cp/iostream.exp
+gdb.cp/local-static.exp
+gdb.cp/mb-inline.exp
+gdb.cp/mb-templates.exp
+gdb.cp/m-data.exp
+gdb.cp/member-name.exp
+gdb.cp/member-ptr.exp
+gdb.cp/method2.exp
+gdb.cp/method.exp
+gdb.cp/meth-typedefs.exp
+gdb.cp/namelessclass.exp
+gdb.cp/namespace-enum.exp
+gdb.cp/namespace.exp
+gdb.cp/namespace-nested-import.exp
+gdb.cp/nested-types.exp
+gdb.cp/nextoverthrow.exp
+gdb.cp/non-trivial-retval.exp
+gdb.cp/noparam.exp
+gdb.cp/nsalias.exp
+gdb.cp/nsdecl.exp
+gdb.cp/nsimport.exp
+gdb.cp/nsnoimports.exp
+gdb.cp/nsrecurs.exp
+gdb.cp/nsstress.exp
+gdb.cp/operator.exp
+gdb.cp/overload-const.exp
+gdb.cp/overload.exp
+gdb.cp/ovsrch.exp
+gdb.cp/paren-type.exp
+gdb.cp/parse-lang.exp
+gdb.cp/pass-by-ref-2.exp
+gdb.cp/pass-by-ref.exp
+gdb.cp/pr-1023.exp
+gdb.cp/pr10687.exp
+gdb.cp/pr10728.exp
+gdb.cp/pr11734.exp
+gdb.cp/pr12028.exp
+gdb.cp/pr-1210.exp
+gdb.cp/pr12273.exp
+gdb.cp/pr17132.exp
+gdb.cp/pr9067.exp
+gdb.cp/pr9631.exp
+gdb.cp/print-demangle.exp
+gdb.cp/printmethod.exp
+gdb.cp/psmang.exp
+gdb.cp/psymtab-parameter.exp
+gdb.cp/ptype-cv-cp.exp
+gdb.cp/ptype-flags.exp
+gdb.cp/punctuator.exp
+gdb.cp/readnow-language.exp
+gdb.cp/ref-params.exp
+gdb.cp/re-set-overloaded.exp
+gdb.cp/rtti.exp
+gdb.cp/rvalue-ref-casts.exp
+gdb.cp/rvalue-ref-params.exp
+gdb.cp/rvalue-ref-sizeof.exp
+gdb.cp/rvalue-ref-types.exp
+gdb.cp/save-bp-qualified.exp
+gdb.cp/scope-err.exp
+gdb.cp/shadow.exp
+gdb.cp/smartp.exp
+gdb.cp/static-method.exp
+gdb.cp/static-print-quit.exp
+gdb.cp/static-typedef-print.exp
+gdb.cp/stub-array-size.exp
+gdb.cp/subtypes.exp
+gdb.cp/try_catch.exp
+gdb.cp/typedef-base.exp
+gdb.cp/typedef-operator.exp
+gdb.cp/typed-enum.exp
+gdb.cp/userdef.exp
+gdb.cp/using-crash.exp
+gdb.cp/virtbase2.exp
+gdb.cp/virtbase.exp
+gdb.cp/virtfunc2.exp
+gdb.cp/wide_char_types.exp
+gdb.fortran/array-bounds.exp
+gdb.fortran/array-bounds-high.exp
+gdb.fortran/array-element.exp
+gdb.fortran/array-slices-bad.exp
+gdb.fortran/array-slices-sub-slices.exp
+gdb.fortran/block-data.exp
+gdb.fortran/charset.exp
+gdb.fortran/class-allocatable-array.exp
+gdb.fortran/common-block.exp
+gdb.fortran/complex.exp
+gdb.fortran/derived-type.exp
+gdb.fortran/derived-type-function.exp
+gdb.fortran/derived-type-striding.exp
+gdb.fortran/dot-ops.exp
+gdb.fortran/exprs.exp
+gdb.fortran/info-modules.exp
+gdb.fortran/info-types.exp
+gdb.fortran/intrinsics.exp
+gdb.fortran/library-module.exp
+gdb.fortran/logical.exp
+gdb.fortran/max-depth.exp
+gdb.fortran/mixed-lang-stack.exp
+gdb.fortran/module.exp
+gdb.fortran/multi-dim.exp
+gdb.fortran/nested-funcs-2.exp
+gdb.fortran/nested-funcs.exp
+gdb.fortran/pointer-to-pointer.exp
+gdb.fortran/print-formatted.exp
+gdb.fortran/printing-types.exp
+gdb.fortran/print_type.exp
+gdb.fortran/ptr-indentation.exp
+gdb.fortran/ptype-on-functions.exp
+gdb.fortran/short-circuit-argument-list.exp
+gdb.fortran/subarray.exp
+gdb.fortran/type-kinds.exp
+gdb.fortran/types.exp
+gdb.fortran/vla-alloc-assoc.exp
+gdb.fortran/vla-datatypes.exp
+gdb.fortran/vla-history.exp
+gdb.fortran/vla-ptr-info.exp
+gdb.fortran/vla-ptype.exp
+gdb.fortran/vla-ptype-sub.exp
+gdb.fortran/vla-sizeof.exp
+gdb.fortran/vla-type.exp
+gdb.fortran/vla-value.exp
+gdb.fortran/vla-value-sub-arbitrary.exp
+gdb.fortran/vla-value-sub.exp
+gdb.fortran/vla-value-sub-finish.exp
+gdb.fortran/whatis_type.exp
+gdb.fortran/xlf-variable.exp
diff --git a/tests/gdb-testsuite-sanity/ref/gen.sh b/tests/gdb-testsuite-sanity/ref/gen.sh
new file mode 100755
index 0000000..0926a71
--- /dev/null
+++ b/tests/gdb-testsuite-sanity/ref/gen.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+BIN=`which gdb` &&
+PACKAGE=`rpm -qf --qf='%{name}\n' ${BIN}` &&
+SYSTEM=`uname -r | grep -o -E 'el[0-9]+a?|fc[0-9]+'` &&
+ARCH=`arch` &&
+echo "./ref/${PACKAGE}/${SYSTEM}.${ARCH}" &&
+exit 0
+
+echo "ERROR" >&2
+exit 1
diff --git a/tests/gdb-testsuite-sanity/runtest.sh b/tests/gdb-testsuite-sanity/runtest.sh
new file mode 100755
index 0000000..b34d5d4
--- /dev/null
+++ b/tests/gdb-testsuite-sanity/runtest.sh
@@ -0,0 +1,136 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# runtest.sh of /tools/gdb/Sanity/gdb-testsuite-sanity
+# Description: gdb testing by upstream testsuite
+# Author: Michal Kolar <mkolar@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2021 Red Hat, Inc.
+#
+# This program is free software: you can 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, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include Beaker environment
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+BUILD_USER=${BUILD_USER:-gdbbld}
+export PACKAGE="${PACKAGE:-$(rpm -qf --qf='%{name}\n' `which gdb`)}"
+RUNTESTFLAGS=${RUNTESTFLAGS:-GDB=`rpm -ql $PACKAGE | grep -E 'bin/gdb$'`}
+TESTS_COUNT_MIN=${TESTS_COUNT_MIN:-4000}
+REQUIRES="$PACKAGE rpm-build dejagnu make gcc glibc"
+if rlIsFedora; then
+ REQUIRES="$REQUIRES dnf-utils"
+else
+ REQUIRES="$REQUIRES yum-utils"
+fi
+
+rlJournalStart
+ rlPhaseStartSetup
+ rlShowRunningKernel
+ rlAssertRpm --all
+ rlRun "TmpDir=\$(mktemp -d)"
+ rlRun "cp -r ./ref $TmpDir"
+ rlRun "pushd $TmpDir"
+ rlFetchSrcForInstalled $PACKAGE
+ rlRun "useradd -M -N $BUILD_USER" 0,9
+ [ $? -eq 0 ] && rlRun "del=yes"
+ rlRun "chown -R $BUILD_USER:users $TmpDir"
+ rlRun "cp /proc/sys/kernel/core_pattern $TmpDir/core_pattern.bckp"
+ rlRun "echo 'core.%p' >/proc/sys/kernel/core_pattern"
+ rlRun "ulimit -c unlimited"
+ rlPhaseEnd
+
+ rlPhaseStartSetup "build gdb"
+ rlRun "su -c 'rpm -D \"_topdir $TmpDir\" -U *.src.rpm &>rpm.log' $BUILD_USER"
+ rlRun "rlFileSubmit $TmpDir/rpm.log rpm.log"
+ rlRun "su -c 'rpmbuild -D \"_topdir $TmpDir\" -bs --with testsuite $TmpDir/SPECS/*.spec &>rpmbuild-bs.log' $BUILD_USER"
+ rlRun "rlFileSubmit $TmpDir/rpmbuild-bs.log rpmbuild-bs.log"
+ rlRun "yum-builddep -y -D \"_topdir $TmpDir\" $TmpDir/SRPMS/*.src.rpm &>$TmpDir/yum-builddep.log" 0,1; ret=$?
+ rlRun "rlFileSubmit $TmpDir/yum-builddep.log yum-builddep.log"
+ if [ $ret -ne 0 ]; then
+ rlLogWarning "Dependencies was not successfully installed"
+ rlLogInfo "Trying to install dependencies of bare SPEC file ..."
+ rlRun "yum-builddep -y -D \"_topdir $TmpDir\" $TmpDir/SPECS/*.spec &>$TmpDir/yum-builddep-spec.log"
+ rlRun "rlFileSubmit $TmpDir/yum-builddep-spec.log yum-builddep-spec.log"
+ fi
+ rlRun "su -c 'rpmbuild -D \"_topdir $TmpDir\" -bp $TmpDir/SPECS/*.spec &>$TmpDir/rpmbuild-bp.log' $BUILD_USER"
+ rlRun "rlFileSubmit $TmpDir/rpmbuild-bp.log rpmbuild-bp.log"
+ if test -e $TmpDir/BUILD/gdb-*/gnulib/configure; then
+ rlRun "cd $TmpDir/BUILD/gdb-*/gnulib"
+ rlRun "su -c 'bash ./configure &>$TmpDir/configure-gnulib.log' $BUILD_USER"
+ rlRun "rlFileSubmit $TmpDir/configure-gnulib.log configure-gnulib.log"
+ fi
+ rlRun "configure_flags=\$(rpmspec -D \"_topdir $TmpDir\" -P $TmpDir/SPECS/*.spec | grep -o -E '\-\-(prefix|with\-gdb\-datadir|with\-separate\-debug\-dir|with\-python)=\S+' | tr '\n' ' ')"
+ rlRun "cd $TmpDir/BUILD/gdb-*/gdb"
+ rlRun "su -c './configure $configure_flags &>$TmpDir/configure.log' $BUILD_USER"
+ rlRun "rlFileSubmit $TmpDir/configure.log configure.log"
+ rlRun "DATADIR=`gdb -ex 'show data-directory' -batch | grep -o -E '/[^\"]+'`"
+ rlRun "mv data-directory data-directory.orig"
+ rlRun "ln -s $DATADIR ./data-directory"
+ rlPhaseEnd
+
+ rlPhaseStartSetup "filter testsuite"
+ rlRun "system=`uname -r | grep -o -E 'el[0-9]+a?|fc[0-9]+'` && [[ ! -z \$system ]]"
+ rlRun "ref_file=$TmpDir/ref/$PACKAGE/$system.`arch`"
+ if ! test -e $ref_file; then
+ rlLogWarning "Reference file $ref_file not found"
+ rlLogInfo "Using default reference file ..."
+ rlRun "ref_file=$TmpDir/ref/default"
+ fi
+ rlRun "test -e $ref_file"
+ rlRun "cd testsuite"
+ rlRun "find . -regex '^./gdb\..+\.exp$' -type f -printf '%P\n' | sort >$TmpDir/test_list"
+ rlRun "comm -23 $TmpDir/test_list $ref_file >$TmpDir/disable_list" # disable tests that are not included in the reference file
+ rlLogInfo "Testcase disabling ..."
+ while read file; do
+ mv "$file" "$file.disabled"
+ done <$TmpDir/disable_list
+ rlRun "cd $TmpDir/BUILD/gdb-*/gdb"
+ rlPhaseEnd
+
+ rlPhaseStartTest "run testsuite"
+ rlRun "su -c 'make check RUNTESTFLAGS=\"${RUNTESTFLAGS}\" |& tee $TmpDir/testsuite.log | grep -E \"^Running.+\.exp ...$\"; test \${PIPESTATUS[0]} -eq 0' $BUILD_USER"
+ rlRun "rlFileSubmit $TmpDir/testsuite.log testsuite.log"
+ rlRun "rlFileSubmit testsuite/gdb.sum gdb.sum"
+ rlRun "rlFileSubmit testsuite/gdb.log gdb.log"
+ rlLogInfo "`awk '/=== gdb Summary ===/,0' testsuite/gdb.sum`"
+ rlPhaseEnd
+
+ rlPhaseStartTest "evaluate results"
+ rlRun "tests_count=\$(grep -E '^PASS:' testsuite/gdb.sum | wc -l)"
+ [ "$tests_count" -ge "$TESTS_COUNT_MIN" ] && rlLogInfo "Test counter: $tests_count" || rlFail "Test counter $tests_count should be greater than or equal to $TESTS_COUNT_MIN"
+ rlRun "awk 'BEGIN { RS=\"Running /tmp/[^/]+/BUILD/gdb-[^/]+/gdb/testsuite/\" } /\sERROR:|\sFAIL:|\sKPASS:|\sUNRESOLVED:|\sXPASS:/ { print \$0 }' testsuite/gdb.sum >$TmpDir/error.log" # check for errors, unresolved testcases, unexpected failures and unexpected successes
+ if [ -s $TmpDir/error.log ]; then
+ rlFail "Errors observed";
+ rlRun "rlFileSubmit $TmpDir/error.log error.log"
+ rlRun "awk 'BEGIN { RS=\"Running /tmp/[^/]+/BUILD/gdb-[^/]+/gdb/testsuite/\" } /\sERROR:|\sFAIL:|\sKPASS:|\sUNRESOLVED:|\sXPASS:/ { print \$1 }' testsuite/gdb.sum >$TmpDir/affected_testcases.log"
+ rlLogInfo "`echo 'Affected testcases:';cat $TmpDir/affected_testcases.log`"
+ rlRun "rlFileSubmit $TmpDir/affected_testcases.log affected_testcases.log"
+ else
+ rlPass "No errors observed"
+ fi
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ rlRun "cat $TmpDir/core_pattern.bckp >/proc/sys/kernel/core_pattern"
+ rlRun "popd"
+ rlRun "rm -r $TmpDir"
+ [ "$del" = "yes" ] && rlRun "userdel -f $BUILD_USER"
+ rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
diff --git a/.gitignore b/.gitignore
index 5f4a40c..e8a3ba8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
/new-fedora-release
/gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz
/v2.0.4.tar.gz
-/gdb-10.2.tar.xz
+/gdb-11.1.tar.xz
diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include
index 219586e..e56cf90 100644
--- a/_gdb.spec.Patch.include
+++ b/_gdb.spec.Patch.include
@@ -19,283 +19,279 @@ Patch004: gdb-6.3-test-movedir-20050125.patch
#=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
+Patch006: 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
+Patch007: 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
+Patch008: 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
+Patch09: gdb-6.5-BEA-testsuite.patch
# Testcase for deadlocking on last address space byte; for corrupted backtraces.
#=fedoratest
-Patch011: gdb-6.5-last-address-space-byte-test.patch
+Patch010: 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
+Patch011: gdb-6.5-readline-long-line-crash-test.patch
# Test sideeffects of skipping ppc .so libs trampolines (BZ 218379).
#=fedoratest
-Patch013: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
+Patch012: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
# Find symbols properly at their original (included) file (BZ 109921).
#=fedoratest
-Patch014: gdb-6.5-bz109921-DW_AT_decl_file-test.patch
+Patch013: 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
+Patch014: 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
+Patch015: 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
+Patch016: gdb-6.6-bz230000-power6-disassembly-test.patch
# Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517).
#=fedoratest
-Patch018: gdb-6.6-bz229517-gcore-without-terminal.patch
+Patch017: 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
+Patch018: 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
+Patch019: 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
+Patch020: 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
+Patch021: 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
+Patch022: 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
+Patch023: gdb-6.6-buildid-locate-solib-missing-ids.patch
#=push+jan
-Patch025: gdb-6.6-buildid-locate-rpm.patch
+Patch024: 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
+Patch025: gdb-6.7-charsign-test.patch
# Test PPC hiding of call-volatile parameter register.
#=fedoratest
-Patch027: gdb-6.7-ppc-clobbered-registers-O2-test.patch
+Patch026: 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
+Patch027: 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
+Patch028: 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
+Patch029: gdb-6.5-missed-trap-on-step-test.patch
# Test gcore memory and time requirements for large inferiors.
#=fedoratest
-Patch031: gdb-6.5-gcore-buffer-limit-test.patch
+Patch030: 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
+Patch031: 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
+Patch032: 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
+Patch033: gdb-6.8-bz442765-threaded-exec-test.patch
# Test a crash on libraries missing the .text section.
#=fedoratest
-Patch035: gdb-6.5-section-num-fixup-test.patch
+Patch034: 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
+Patch035: 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
+Patch036: 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
+Patch037: 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
+Patch038: gdb-ccache-workaround.patch
# Testcase for "Do not make up line information" fix by Daniel Jacobowitz.
#=fedoratest
-Patch040: gdb-lineno-makeup-test.patch
+Patch039: gdb-lineno-makeup-test.patch
# Test power7 ppc disassembly.
#=fedoratest
-Patch041: gdb-ppc-power7-test.patch
+Patch040: gdb-ppc-power7-test.patch
# Fix follow-exec for C++ programs (bugreported by Martin Stransky).
#=fedoratest
-Patch042: gdb-archer-next-over-throw-cxx-exec.patch
+Patch041: gdb-archer-next-over-throw-cxx-exec.patch
# Backport DWARF-4 support (BZ 601887, Tom Tromey).
#=fedoratest
-Patch043: gdb-bz601887-dwarf4-rh-test.patch
+Patch042: gdb-bz601887-dwarf4-rh-test.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
+Patch043: 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
+Patch044: 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
+Patch045: 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
+Patch046: gdb-test-pid0-core.patch
# [archer-tromey-delayed-symfile] New test gdb.dwarf2/dw2-aranges.exp.
#=fedoratest
-Patch048: gdb-test-dw2-aranges.patch
+Patch047: gdb-test-dw2-aranges.patch
# [archer-keiths-expr-cumulative+upstream] Import C++ testcases.
#=fedoratest
-Patch049: gdb-test-expr-cumulative-archer.patch
+Patch048: 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
+Patch049: gdb-physname-pr11734-test.patch
# Fix regressions on C++ names resolving (PR 11734, PR 12273, Keith Seitz).
#=fedoratest
-Patch051: gdb-physname-pr12273-test.patch
+Patch050: gdb-physname-pr12273-test.patch
# Test GDB opcodes/ disassembly of Intel Ivy Bridge instructions (BZ 696890).
#=fedoratest
-Patch052: gdb-test-ivy-bridge.patch
+Patch051: gdb-test-ivy-bridge.patch
# Hack for proper PIE run of the testsuite.
#=fedoratest
-Patch053: gdb-runtest-pie-override.patch
+Patch052: gdb-runtest-pie-override.patch
# Workaround PR libc/14166 for inferior calls of strstr.
#=fedoratest: Compatibility with RHELs (unchecked which ones).
-Patch054: gdb-glibc-strstr-workaround.patch
+Patch053: 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
+Patch054: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
# Testcase for `Setting solib-absolute-prefix breaks vDSO' (BZ 818343).
#=fedoratest
-Patch056: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch
+Patch055: 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
+Patch056: 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
+Patch057: 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
+Patch058: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
# Display Fortran strings in backtraces.
#=fedoratest
-Patch060: gdb-fortran-frame-string.patch
+Patch059: gdb-fortran-frame-string.patch
# Testcase for '[SAP] Recursive dlopen causes SAP HANA installer to
# crash.' (RH BZ 1156192).
#=fedoratest
-Patch061: gdb-rhbz1156192-recursive-dlopen-test.patch
+Patch060: 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
+Patch061: 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
+Patch062: 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
+Patch063: gdb-rhbz1350436-type-printers-error.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
+Patch064: 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
+Patch065: gdb-fedora-libncursesw.patch
# Test clflushopt instruction decode (for RH BZ 1262471).
#=fedoratest
-Patch067: gdb-opcodes-clflushopt-test.patch
+Patch066: 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
+Patch067: gdb-6.6-buildid-locate-rpm-scl.patch
# [aarch64] Fix hardware watchpoints (RH BZ 1261564).
#=fedoratest
-Patch069: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
+Patch068: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
# Add messages suggesting more recent RHEL gdbserver (RH BZ 1321114).
#=fedora
-Patch070: gdb-container-rh-pkg.patch
+Patch069: 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
+Patch070: gdb-rhbz1325795-framefilters-test.patch
# [dts+el7] [x86*] Bundle linux_perf.h for libipt (RH BZ 1256513).
#=fedora
-Patch072: gdb-linux_perf-bundle.patch
+Patch071: gdb-linux_perf-bundle.patch
# Fix gdb-headless /usr/bin/ executables (BZ 1390251).
#
@@ -304,102 +300,54 @@ Patch072: gdb-linux_perf-bundle.patch
#
# https://fedoraproject.org/wiki/Changes/Minimal_GDB_in_buildroot
#=fedora
-Patch073: gdb-libexec-add-index.patch
+Patch072: gdb-libexec-add-index.patch
# New testcase for: Fix <tab>-completion crash (Gary Benson, RH BZ 1398387).
#=fedoratest
-Patch074: gdb-rhbz1398387-tab-crash-test.patch
+Patch073: gdb-rhbz1398387-tab-crash-test.patch
# [s390x] Backport arch12 instructions decoding (RH BZ 1553104).
# =fedoratest
-Patch075: gdb-rhbz1553104-s390x-arch12-test.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
-
-# Backport fix for libstdc++ assert when performing tab completion
-# (RH BZ 1912985).
-Patch077: gdb-rhbz1912985-libstdc++-assert.patch
-
-# Backport fix for frame_id_p assertion failure (RH BZ 1909902).
-Patch078: gdb-rhbz1909902-frame_id_p-assert-1.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
-
-# 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
-
-# [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
-
-# [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
+Patch074: gdb-rhbz1553104-s390x-arch12-test.patch
-# [fortran] Backport Andrew Burgess's commit which adds support
-# for array strides in expressions.
-Patch088: gdb-rhbz1964167-fortran-array-strides-in-expressions.patch
+#Backport upstream patch which fixes internal-error: Unexpected
+#type field location kind (RHBZ 1976887).
+Patch075: gdb-rhbz1976887-field-location-kind.patch
-# [fortran] Backport Andrew Burgess's commit for Fortran array
-# slice support
-Patch089: gdb-rhbz1964167-fortran-array-slices-at-prompt.patch
+# Backport test for RHBZ 1976887 (Kevin Buettner).
+Patch076: gdb-test-for-rhbz1976887.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 gdb.fortran testsuite changes in order to avoid Fortran
+# lexical analyzer bug.
+Patch077: gdb-rhbz2012976-paper-over-fortran-lex-problems.patch
-# Backport of "Exclude debuginfo files from 'outside of ELF segments'
-# warning" (Keith Seitz)
-Patch091: gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch
+# Backport manpage update
+Patch078: gdb-rhbz-853071-update-manpages.patch
-# Backport "Fix crash when expanding partial symtabs with DW_TAG_imported_unit"
-# (Tom Tromey, gdb/27743)
-Patch092: gdb-gdb27743-psymtab-imported-unit.patch
+# Backport fix for dprintf bug (RH BZ 2022177).
+Patch079: gdb-rhbz2022177-dprintf-1.patch
-# Backport "[gdb/server] Don't overwrite fs/gs_base with -m32"
-# (Tom de Vries)
-Patch093: gdb-dont-overwrite-fsgsbase-m32.patch
+# Backport test case for dprintf bug (RH BZ 2022177).
+Patch080: gdb-rhbz2022177-dprintf-2.patch
-# Backport patch fixing gdb on glibc-2.34 machines with regard to attaching
-# to processes (RH BZ 1971096).
-Patch094: gdb-rhbz1971096-glibc2.34-1.patch
+#Backport upstream commit from Aaron Merey
+#3ea44f21299 gdb.texinfo: Expand documentation for debuginfod
+Patch081: gdb-rhbz2024875-expand-documentation-for-debuginfod.patch
-# Backport patch fixing gdb on glibc-2.34 machines w/ regard to
-# libthread_db initialization.
-Patch095: gdb-rhbz1971096-glibc2.34-2.patch
+#Backport upstream commit from Aaron Merey
+#7811fa5995f gdb: add set/show commands for managing debuginfo
+Patch082: gdb-rhbz2024875-set_show-for-managing-debuginfod.patch
-# Backport testsuite patch for matching new libthread_db related output
-# when testing gdb on glibc-2.34 matchines (RH BZ 1971096).
-Patch096: gdb-rhbz1971096-glibc2.34-3.patch
+#Backport upstream commit from Tom Tromey
+#2a8f1f47446 Fix unittest.exp failure due to 'set debuginfod' addition
+Patch083: gdb-rhbz2024875-fix-unittest-failure.patch
-# Backport patch adjusting test gdb.base/print-symbol-loading.exp.
-# (RH BZ 1971096).
-Patch097: gdb-rhbz1971096-glibc2.34-4.patch
+#Backport upstream commit from Simon Marchi
+#333f35b6315 gdb: pass/return setting setter/getter
+#scalar values by value
+Patch084: gdb-rhbz202487-rework-set-debuginfod.patch
-# Backport patch adjusting test gdb.mi/mi-sym-info.exp (RH BZ 1971096).
-Patch098: gdb-rhbz1971096-glibc2.34-5.patch
+#Backport upstream commit from Aaron Merey
+#b9db26b4c44 [PR gdb/27026] CTRL-C is ignored when debug info is downloaded
+Patch085: gdb-rhbz2024875-pr27026.patch
diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include
index b089bb1..9594d35 100644
--- a/_gdb.spec.patch.include
+++ b/_gdb.spec.patch.include
@@ -83,16 +83,3 @@
%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
diff --git a/_git_upstream_commit b/_git_upstream_commit
index 02c1a0f..349e76b 100644
--- a/_git_upstream_commit
+++ b/_git_upstream_commit
@@ -1 +1 @@
-ce35d7163e779b1321058b22f005c70ce1524b25
+8cdd8568bfe4ea86a93e4b80bf2fc6e6f9cad84c
diff --git a/_patch_order b/_patch_order
index a767691..de20617 100644
--- a/_patch_order
+++ b/_patch_order
@@ -3,7 +3,6 @@ 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
@@ -73,26 +72,14 @@ 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-gdb27743-psymtab-imported-unit.patch
-gdb-dont-overwrite-fsgsbase-m32.patch
-gdb-rhbz1971096-glibc2.34-1.patch
-gdb-rhbz1971096-glibc2.34-2.patch
-gdb-rhbz1971096-glibc2.34-3.patch
-gdb-rhbz1971096-glibc2.34-4.patch
-gdb-rhbz1971096-glibc2.34-5.patch
+gdb-rhbz1976887-field-location-kind.patch
+gdb-test-for-rhbz1976887.patch
+gdb-rhbz2012976-paper-over-fortran-lex-problems.patch
+gdb-rhbz-853071-update-manpages.patch
+gdb-rhbz2022177-dprintf-1.patch
+gdb-rhbz2022177-dprintf-2.patch
+gdb-rhbz2024875-expand-documentation-for-debuginfod.patch
+gdb-rhbz2024875-set_show-for-managing-debuginfod.patch
+gdb-rhbz2024875-fix-unittest-failure.patch
+gdb-rhbz202487-rework-set-debuginfod.patch
+gdb-rhbz2024875-pr27026.patch
diff --git a/gdb-6.3-gstack-20050411.patch b/gdb-6.3-gstack-20050411.patch
index 35c2de1..9fa2e7d 100644
--- a/gdb-6.3-gstack-20050411.patch
+++ b/gdb-6.3-gstack-20050411.patch
@@ -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
+@@ -1753,7 +1753,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
install: all
@$(MAKE) $(FLAGS_TO_PASS) install-only
@@ -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:
+@@ -1802,7 +1802,25 @@ install-guile:
install-python:
$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
@@ -52,7 +52,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e $$t` ; \
if test "x$$transformed_name" = x; then \
-@@ -1798,6 +1816,18 @@ uninstall: force $(CONFIG_UNINSTALL)
+@@ -1825,6 +1843,18 @@ uninstall: force $(CONFIG_UNINSTALL)
fi
@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
diff --git a/gdb-6.3-inferior-notification-20050721.patch b/gdb-6.3-inferior-notification-20050721.patch
deleted file mode 100644
index 894ef79..0000000
--- a/gdb-6.3-inferior-notification-20050721.patch
+++ /dev/null
@@ -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);
-+}
diff --git a/gdb-6.3-rh-testversion-20041202.patch b/gdb-6.3-rh-testversion-20041202.patch
index c1e7395..7ee68e4 100644
--- a/gdb-6.3-rh-testversion-20041202.patch
+++ b/gdb-6.3-rh-testversion-20041202.patch
@@ -27,7 +27,7 @@ diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest
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)
+@@ -2195,7 +2195,7 @@ init_gdb_version_vars (void)
struct internalvar *major_version_var = create_internalvar ("_gdb_major");
struct internalvar *minor_version_var = create_internalvar ("_gdb_minor");
int vmajor = 0, vminor = 0, vrevision = 0;
diff --git a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
index 5cdf65f..304aa38 100644
--- a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
+++ b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
@@ -44,17 +44,17 @@ 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)
+@@ -1306,6 +1306,10 @@ process_print_command_args (const char *args, value_print_options *print_opts,
if (exp != nullptr && *exp)
{
+ /* '*((int *(*) (void)) __errno_location) ()' is incompatible with
+ function descriptors. */
-+ if (target_has_execution && strcmp (exp, "errno") == 0)
++ if (target_has_execution () && strcmp (exp, "errno") == 0)
+ exp = "*(*(int *(*)(void)) __errno_location) ()";
- expression_up expr = parse_expression (exp);
- val = evaluate_expression (expr.get ());
- }
+ /* VOIDPRINT is true to indicate that we do want to print a void
+ value, so invert it for parse_expression. */
+ expression_up expr = parse_expression (exp, nullptr, !voidprint);
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c
new file mode 100644
--- /dev/null
diff --git a/gdb-6.6-buildid-locate-rpm-scl.patch b/gdb-6.6-buildid-locate-rpm-scl.patch
index 81056cc..1dc3ac4 100644
--- a/gdb-6.6-buildid-locate-rpm-scl.patch
+++ b/gdb-6.6-buildid-locate-rpm-scl.patch
@@ -98,7 +98,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
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,
+@@ -2801,6 +2801,16 @@ read_gdb_index_from_buffer (const char *filename,
"set use-deprecated-index-sections on". */
if (version < 6 && !deprecated_ok)
{
@@ -115,7 +115,7 @@ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
static int warning_printed = 0;
if (!warning_printed)
{
-@@ -3045,6 +3055,10 @@ to use the section anyway."),
+@@ -2812,6 +2822,10 @@ to use the section anyway."),
warning_printed = 1;
}
return 0;
diff --git a/gdb-6.6-buildid-locate-rpm.patch b/gdb-6.6-buildid-locate-rpm.patch
index bf783da..4693f43 100644
--- a/gdb-6.6-buildid-locate-rpm.patch
+++ b/gdb-6.6-buildid-locate-rpm.patch
@@ -696,7 +696,7 @@ diff --git a/gdb/config.in b/gdb/config.in
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
-@@ -247,6 +250,9 @@
+@@ -246,6 +249,9 @@
/* Define if you have the mpfr library. */
#undef HAVE_LIBMPFR
@@ -709,7 +709,7 @@ diff --git a/gdb/config.in b/gdb/config.in
diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
-@@ -769,6 +769,11 @@ PKG_CONFIG
+@@ -771,6 +771,11 @@ PKG_CONFIG
HAVE_NATIVE_GCORE_TARGET
TARGET_OBS
subdirs
@@ -721,7 +721,7 @@ diff --git a/gdb/configure b/gdb/configure
GDB_DATADIR
DEBUGDIR
MAKEINFO_EXTRA_FLAGS
-@@ -873,6 +878,7 @@ with_gdb_datadir
+@@ -876,6 +881,7 @@ with_gdb_datadir
with_relocated_sources
with_auto_load_dir
with_auto_load_safe_path
@@ -729,7 +729,7 @@ diff --git a/gdb/configure b/gdb/configure
enable_targets
enable_64_bit_bfd
enable_gdbmi
-@@ -949,6 +955,8 @@ PKG_CONFIG_PATH
+@@ -953,6 +959,8 @@ PKG_CONFIG_PATH
PKG_CONFIG_LIBDIR
DEBUGINFOD_CFLAGS
DEBUGINFOD_LIBS
@@ -738,7 +738,7 @@ diff --git a/gdb/configure b/gdb/configure
YACC
YFLAGS
XMKMF'
-@@ -1621,6 +1629,8 @@ Optional Packages:
+@@ -1625,6 +1633,8 @@ Optional Packages:
do not restrict auto-loaded files locations
--with-debuginfod Enable debuginfo lookups with debuginfod
(auto/yes/no)
@@ -747,7 +747,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:
+@@ -1705,6 +1715,8 @@ Some influential environment variables:
C compiler flags for DEBUGINFOD, overriding pkg-config
DEBUGINFOD_LIBS
linker flags for DEBUGINFOD, overriding pkg-config
@@ -756,7 +756,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
+@@ -6616,6 +6628,494 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
$as_echo "$with_auto_load_safe_path" >&6; }
@@ -1254,7 +1254,7 @@ diff --git a/gdb/configure b/gdb/configure
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
-@@ -143,6 +143,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
+@@ -153,6 +153,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
[Directories safe to hold auto-loaded files.])
AC_MSG_RESULT([$with_auto_load_safe_path])
@@ -1457,7 +1457,7 @@ 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 @@
+@@ -41,6 +41,7 @@
#include "gdbsupport/gdb_select.h"
#include "gdbsupport/gdb-sigmask.h"
#include "async-event.h"
@@ -1465,7 +1465,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
/* readline include files. */
#include "readline/readline.h"
-@@ -364,6 +365,8 @@ display_gdb_prompt (const char *new_prompt)
+@@ -363,6 +364,8 @@ display_gdb_prompt (const char *new_prompt)
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
@@ -1489,11 +1489,11 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
diff --git a/gdb/symfile.h b/gdb/symfile.h
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
-@@ -560,6 +560,7 @@ extern void generic_load (const char *args, int from_tty);
+@@ -342,6 +342,7 @@ extern void generic_load (const char *args, int from_tty);
/* build-id support. */
extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
extern void debug_print_missing (const char *binary, const char *debug);
+extern void debug_flush_missing (void);
#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
- /* From dwarf2read.c */
+ /* From minidebug.c. */
diff --git a/gdb-6.6-buildid-locate-solib-missing-ids.patch b/gdb-6.6-buildid-locate-solib-missing-ids.patch
index f1f5e83..7dd4fb1 100644
--- a/gdb-6.6-buildid-locate-solib-missing-ids.patch
+++ b/gdb-6.6-buildid-locate-solib-missing-ids.patch
@@ -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,
+@@ -1350,14 +1350,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,
+@@ -1372,23 +1386,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;
- }
diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch
index f606793..e9ee342 100644
--- a/gdb-6.6-buildid-locate.patch
+++ b/gdb-6.6-buildid-locate.patch
@@ -9,7 +9,7 @@ Subject: gdb-6.6-buildid-locate.patch
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
-@@ -121,7 +121,7 @@ static inline char *
+@@ -115,7 +115,7 @@ static inline char *
bfd_strdup (const char *str)
{
size_t len = strlen (str) + 1;
@@ -21,7 +21,7 @@ diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
-@@ -126,7 +126,7 @@ static inline char *
+@@ -120,7 +120,7 @@ static inline char *
bfd_strdup (const char *str)
{
size_t len = strlen (str) + 1;
@@ -890,7 +890,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
+ char *build_id_filename_cstr = NULL;
gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size,
- build_id->data));
-+ build_id->data,
++ build_id->data,
+ (!build_id_filename_return ? NULL : &build_id_filename_cstr)));
+ if (build_id_filename_return)
+ {
@@ -906,15 +906,15 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
/* Prevent looping on a stripped .debug file. */
if (abfd != NULL
&& filename_cmp (bfd_get_filename (abfd.get ()),
-@@ -223,3 +897,21 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
+@@ -223,3 +897,22 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
return std::string ();
}
+
-+extern void _initialize_build_id (void);
++void _initialize_build_id ();
+
+void
-+_initialize_build_id (void)
++_initialize_build_id ()
+{
+ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose,
+ _("\
@@ -926,7 +926,8 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
+ show_build_id_verbose,
+ &setlist, &showlist);
+
-+ gdb::observers::executable_changed.attach (debug_print_executable_changed);
++ gdb::observers::executable_changed.attach (debug_print_executable_changed,
++ "build-id");
+}
diff --git a/gdb/build-id.h b/gdb/build-id.h
--- a/gdb/build-id.h
@@ -950,7 +951,7 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h
extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len,
- const bfd_byte *build_id);
+ const bfd_byte *build_id,
-+ char **link_return);
++ char **link_return = NULL);
+
+extern char *build_id_to_filename (const struct bfd_build_id *build_id,
+ char **link_return);
@@ -978,9 +979,9 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h
diff --git a/gdb/coffread.c b/gdb/coffread.c
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
-@@ -709,7 +709,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
+@@ -710,7 +710,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
/* Try to add separate debug file if no symbols table found. */
- if (!objfile_has_partial_symbols (objfile))
+ if (!objfile->has_partial_symbols ())
{
- std::string debugfile = find_separate_debug_file_by_buildid (objfile);
+ std::string debugfile = find_separate_debug_file_by_buildid (objfile,
@@ -1002,7 +1003,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
#include "inferior.h"
#include "infrun.h"
#include "symtab.h"
-@@ -362,6 +366,8 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
+@@ -356,6 +360,8 @@ add_to_thread_list (asection *asect, asection *reg_sect)
switch_to_thread (thr); /* Yes, make it current. */
}
@@ -1011,7 +1012,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
/* Issue a message saying we have no core to debug, if FROM_TTY. */
static void
-@@ -398,19 +404,25 @@ core_file_command (const char *filename, int from_tty)
+@@ -392,19 +398,26 @@ core_file_command (const char *filename, int from_tty)
static void
locate_exec_from_corefile_build_id (bfd *abfd, int from_tty)
{
@@ -1031,16 +1032,17 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
exec_file_attach (bfd_get_filename (execbfd.get ()), from_tty);
symbol_file_add_main (bfd_get_filename (execbfd.get ()),
symfile_add_flag (from_tty ? SYMFILE_VERBOSE : 0));
-+ if (symfile_objfile != NULL)
-+ symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
++ if (current_program_space->symfile_object_file != NULL)
++ current_program_space->symfile_object_file->flags |=
++ OBJF_BUILD_ID_CORE_LOADED;
}
+ else
+ debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename);
}
/* See gdbcore.h. */
-@@ -1189,4 +1201,11 @@ _initialize_corelow ()
- maintenance_print_core_file_backed_mappings,
+@@ -1209,4 +1222,11 @@ _initialize_corelow ()
+ maintenance_print_core_file_backed_mappings,
_("Print core file's file-backed mappings."),
&maintenanceprintlist);
+
@@ -1054,7 +1056,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
-@@ -21074,6 +21074,27 @@ information files.
+@@ -21415,6 +21415,27 @@ information files.
@end table
@@ -1107,16 +1109,7 @@ diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
-@@ -2225,7 +2225,7 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd)
- }
-
- if (dwz_bfd == NULL)
-- dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid);
-+ dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid, NULL);
-
- if (dwz_bfd == nullptr)
- {
-@@ -5989,7 +5989,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner)
+@@ -5447,7 +5447,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner)
static gdb::array_view<const gdb_byte>
get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd)
{
@@ -1125,7 +1118,7 @@ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
if (build_id == nullptr)
return {};
-@@ -6002,7 +6002,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd)
+@@ -5460,7 +5460,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd)
static gdb::array_view<const gdb_byte>
get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz)
{
@@ -1137,7 +1130,7 @@ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
diff --git a/gdb/elfread.c b/gdb/elfread.c
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
-@@ -1298,7 +1298,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
+@@ -1272,7 +1272,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
&& objfile->separate_debug_objfile == NULL
&& objfile->separate_debug_objfile_backlink == NULL)
{
@@ -1148,7 +1141,7 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c
if (debugfile.empty ())
debugfile = find_separate_debug_file_by_debuglink (objfile);
-@@ -1313,7 +1315,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
+@@ -1287,7 +1289,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
else
{
has_dwarf2 = false;
@@ -1157,7 +1150,7 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c
if (build_id != nullptr)
{
-@@ -1338,6 +1340,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
+@@ -1312,6 +1314,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
has_dwarf2 = true;
}
}
@@ -1171,16 +1164,16 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c
diff --git a/gdb/exec.c b/gdb/exec.c
--- a/gdb/exec.c
+++ b/gdb/exec.c
-@@ -264,7 +264,7 @@ validate_exec_file (int from_tty)
- reopen_exec_file ();
+@@ -237,7 +237,7 @@ validate_exec_file (int from_tty)
current_exec_file = get_exec_file (0);
-- const bfd_build_id *exec_file_build_id = build_id_bfd_get (exec_bfd);
-+ const bfd_build_id *exec_file_build_id = build_id_bfd_shdr_get (exec_bfd);
+ const bfd_build_id *exec_file_build_id
+- = build_id_bfd_get (current_program_space->exec_bfd ());
++ = build_id_bfd_shdr_get (current_program_space->exec_bfd ());
if (exec_file_build_id != nullptr)
{
/* Prepend the target prefix, to force gdb_bfd_open to open the
-@@ -277,7 +277,7 @@ validate_exec_file (int from_tty)
+@@ -250,7 +250,7 @@ validate_exec_file (int from_tty)
if (abfd != nullptr)
{
const bfd_build_id *target_exec_file_build_id
@@ -1192,7 +1185,7 @@ diff --git a/gdb/exec.c b/gdb/exec.c
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
-@@ -714,6 +714,10 @@ struct objfile
+@@ -812,6 +812,10 @@ struct objfile
bool skip_jit_symbol_lookup = false;
};
@@ -1235,7 +1228,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
static int svr4_have_link_map_offsets (void);
-@@ -1338,9 +1339,51 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
+@@ -1348,9 +1349,51 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
continue;
}
@@ -1277,8 +1270,8 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
+ instead) if the on-disk files no longer match the
+ running program version. */
+
-+ if (symfile_objfile != NULL
-+ && (symfile_objfile->flags
++ if (current_program_space->symfile_object_file != NULL
++ && (current_program_space->symfile_object_file->flags
+ & OBJF_BUILD_ID_CORE_LOADED) != 0)
+ newobj->so_name[0] = 0;
+ }
@@ -1293,7 +1286,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
diff --git a/gdb/source.c b/gdb/source.c
--- a/gdb/source.c
+++ b/gdb/source.c
-@@ -1165,7 +1165,7 @@ open_source_file (struct symtab *s)
+@@ -1178,7 +1178,7 @@ open_source_file (struct symtab *s)
srcpath += s->filename;
}
@@ -1305,9 +1298,9 @@ diff --git a/gdb/source.c b/gdb/source.c
diff --git a/gdb/symfile.h b/gdb/symfile.h
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
-@@ -550,12 +550,18 @@ void expand_symtabs_matching
- void map_symbol_filenames (symbol_filename_ftype *fun, void *data,
- int need_fullname);
+@@ -332,12 +332,18 @@ bool expand_symtabs_matching
+ void map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun,
+ bool need_fullname);
+
/* Target-agnostic function to load the sections of an executable into memory.
@@ -1321,9 +1314,9 @@ diff --git a/gdb/symfile.h b/gdb/symfile.h
+extern void debug_print_missing (const char *binary, const char *debug);
+#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
+
- /* From dwarf2read.c */
+ /* From minidebug.c. */
- /* Names for a dwarf2 debugging section. The field NORMAL is the normal
+ extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *);
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -1364,7 +1357,7 @@ diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefi
diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp
--- a/gdb/testsuite/gdb.base/gdbinit-history.exp
+++ b/gdb/testsuite/gdb.base/gdbinit-history.exp
-@@ -181,7 +181,8 @@ proc test_empty_history_filename { } {
+@@ -185,7 +185,8 @@ proc test_empty_history_filename { } {
global env
global gdb_prompt
@@ -1388,7 +1381,17 @@ diff --git a/gdb/testsuite/gdb.base/new-ui-pending-input.exp b/gdb/testsuite/gdb
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
-@@ -2011,6 +2011,17 @@ proc default_gdb_start { } {
+@@ -130,7 +130,8 @@ if ![info exists INTERNAL_GDBFLAGS] {
+ "-nx" \
+ "-data-directory $BUILD_DATA_DIRECTORY" \
+ {-iex "set height 0"} \
+- {-iex "set width 0"}]]
++ {-iex "set width 0"} \
++ {-iex "set build-id-verbose 0"}]]
+ }
+
+ # The variable gdb_prompt is a regexp which matches the gdb prompt.
+@@ -2130,6 +2131,17 @@ proc default_gdb_start { } {
}
}
@@ -1409,7 +1412,7 @@ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
-@@ -308,6 +308,16 @@ proc default_mi_gdb_start { args } {
+@@ -322,6 +322,16 @@ proc default_mi_gdb_start { args } {
warning "Couldn't set the width to 0."
}
}
diff --git a/gdb-ccache-workaround.patch b/gdb-ccache-workaround.patch
index 60bc5cc..802fa2b 100644
--- a/gdb-ccache-workaround.patch
+++ b/gdb-ccache-workaround.patch
@@ -9,8 +9,8 @@ Subject: gdb-ccache-workaround.patch
diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp
--- a/gdb/testsuite/gdb.base/macscp.exp
+++ b/gdb/testsuite/gdb.base/macscp.exp
-@@ -25,6 +25,14 @@ if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } {
- lappend options additional_flags=-g3
+@@ -27,6 +27,14 @@ if { [test_compiler_info "gcc-*"] } {
+ lappend options additional_flags=-fdebug-macro
}
+# Workaround ccache making lineno non-zero for command-line definitions.
diff --git a/gdb-container-rh-pkg.patch b/gdb-container-rh-pkg.patch
index 04a7f3c..0996495 100644
--- a/gdb-container-rh-pkg.patch
+++ b/gdb-container-rh-pkg.patch
@@ -9,7 +9,7 @@ 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)
+@@ -14290,7 +14290,17 @@ remote_target::pid_to_exec_file (int pid)
char *annex = NULL;
if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
diff --git a/gdb-dont-overwrite-fsgsbase-m32.patch b/gdb-dont-overwrite-fsgsbase-m32.patch
deleted file mode 100644
index ee9ad49..0000000
--- a/gdb-dont-overwrite-fsgsbase-m32.patch
+++ /dev/null
@@ -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
diff --git a/gdb-fedora-libncursesw.patch b/gdb-fedora-libncursesw.patch
index 7c620fb..10710b9 100644
--- a/gdb-fedora-libncursesw.patch
+++ b/gdb-fedora-libncursesw.patch
@@ -12,7 +12,7 @@ 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
+@@ -9544,6 +9544,7 @@ if test x"$prefer_curses" = xyes; then
# search /usr/local/include, if ncurses is installed in /usr/local. A
# default installation of ncurses on alpha*-dec-osf* will lead to such
# a situation.
@@ -20,7 +20,7 @@ diff --git a/gdb/configure b/gdb/configure
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing waddstr" >&5
$as_echo_n "checking for library containing waddstr... " >&6; }
if ${ac_cv_search_waddstr+:} false; then :
-@@ -9673,7 +9674,7 @@ return waddstr ();
+@@ -9568,7 +9569,7 @@ return waddstr ();
return 0;
}
_ACEOF
@@ -29,7 +29,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
+@@ -9642,6 +9643,7 @@ case $host_os in
esac
# These are the libraries checked by Readline.
@@ -37,7 +37,7 @@ diff --git a/gdb/configure b/gdb/configure
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
$as_echo_n "checking for library containing tgetent... " >&6; }
if ${ac_cv_search_tgetent+:} false; then :
-@@ -9771,7 +9773,7 @@ return tgetent ();
+@@ -9666,7 +9668,7 @@ return tgetent ();
return 0;
}
_ACEOF
@@ -49,7 +49,7 @@ diff --git a/gdb/configure b/gdb/configure
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
-@@ -712,7 +712,8 @@ if test x"$prefer_curses" = xyes; then
+@@ -736,7 +736,8 @@ if test x"$prefer_curses" = xyes; then
# search /usr/local/include, if ncurses is installed in /usr/local. A
# default installation of ncurses on alpha*-dec-osf* will lead to such
# a situation.
@@ -59,7 +59,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac
if test "$ac_cv_search_waddstr" != no; then
curses_found=yes
-@@ -754,7 +755,8 @@ case $host_os in
+@@ -778,7 +779,8 @@ case $host_os in
esac
# These are the libraries checked by Readline.
diff --git a/gdb-gdb27743-psymtab-imported-unit.patch b/gdb-gdb27743-psymtab-imported-unit.patch
deleted file mode 100644
index c129b6d..0000000
--- a/gdb-gdb27743-psymtab-imported-unit.patch
+++ /dev/null
@@ -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 .*"
diff --git a/gdb-linux_perf-bundle.patch b/gdb-linux_perf-bundle.patch
index 728f463..e3ce1a3 100644
--- a/gdb-linux_perf-bundle.patch
+++ b/gdb-linux_perf-bundle.patch
@@ -213,7 +213,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], [
+@@ -135,7 +135,7 @@ AC_DEFUN([GDB_AC_COMMON], [
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#include <linux/perf_event.h>
#ifndef PERF_ATTR_SIZE_VER5
diff --git a/gdb-rhbz-853071-update-manpages.patch b/gdb-rhbz-853071-update-manpages.patch
new file mode 100644
index 0000000..7ceb67e
--- /dev/null
+++ b/gdb-rhbz-853071-update-manpages.patch
@@ -0,0 +1,258 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Bruno Larsen <blarsen@redhat.com>
+Date: Tue, 9 Nov 2021 14:07:26 -0300
+Subject: gdb-rhbz-853071-update-manpages.patch
+
+;; Backport manpage update
+
+[gdb/doc]: Updated manpages to be consistent with help
+
+Updated manpages to be consistent with help information provided by the
+binary. The main changes are:
+
+* Making all long-form options have '--', instead of a single '-';
+* added most of the missing options to the manpage;
+* removed the information about using '+' instead of '-', since it
+ doesn't seem to be supported anymore.
+
+This also fixes 2 upstream bugs:
+* https://sourceware.org/bugzilla/show_bug.cgi?id=23965; by adding
+--args to the manpage
+* https://sourceware.org/bugzilla/show_bug.cgi?id=10619; by adding the
+double dashes
+
+diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
+--- a/gdb/doc/gdb.texinfo
++++ b/gdb/doc/gdb.texinfo
+@@ -47030,14 +47030,7 @@ switch (die->tag)
+ @c man title gdb The GNU Debugger
+
+ @c man begin SYNOPSIS gdb
+-gdb [@option{-help}] [@option{-nh}] [@option{-nx}] [@option{-q}]
+-[@option{-batch}] [@option{-cd=}@var{dir}] [@option{-f}]
+-[@option{-b}@w{ }@var{bps}]
+- [@option{-tty=}@var{dev}] [@option{-s} @var{symfile}]
+-[@option{-e}@w{ }@var{prog}] [@option{-se}@w{ }@var{prog}]
+-[@option{-c}@w{ }@var{core}] [@option{-p}@w{ }@var{procID}]
+- [@option{-x}@w{ }@var{cmds}] [@option{-d}@w{ }@var{dir}]
+-[@var{prog}|@var{prog} @var{procID}|@var{prog} @var{core}]
++gdb [OPTIONS] [@var{prog}|@var{prog} @var{procID}|@var{prog} @var{core}]
+ @c man end
+
+ @c man begin DESCRIPTION gdb
+@@ -47101,8 +47094,8 @@ Here are some of the most frequently needed @value{GDBN} commands:
+
+ @c pod2man highlights the right hand side of the @item lines.
+ @table @env
+-@item break [@var{file}:]@var{function}
+-Set a breakpoint at @var{function} (in @var{file}).
++@item break [@var{file}:][@var{function}|@var{line}]
++Set a breakpoint at @var{function} or @var{line} (in @var{file}).
+
+ @item run [@var{arglist}]
+ Start your program (with @var{arglist}, if specified).
+@@ -47150,72 +47143,91 @@ as the @code{gdb} entry in the @code{info} program.
+ Any arguments other than options specify an executable
+ file and core file (or process ID); that is, the first argument
+ encountered with no
+-associated option flag is equivalent to a @option{-se} option, and the second,
++associated option flag is equivalent to a @option{--se} option, and the second,
+ if any, is equivalent to a @option{-c} option if it's the name of a file.
+ Many options have
+-both long and short forms; both are shown here. The long forms are also
++both long and abbreviated forms; both are shown here. The long forms are also
+ recognized if you truncate them, so long as enough of the option is
+-present to be unambiguous. (If you prefer, you can flag option
+-arguments with @option{+} rather than @option{-}, though we illustrate the
+-more usual convention.)
++present to be unambiguous.
++
++The abbreviated forms are shown here with @samp{-} and long forms are shown
++with @samp{--} to reflect how they are shown in @option{--help}. However,
++@value{GDBN} recognizes all of the following conventions for most options:
++
++@table @code
++@item --option=@var{value}
++@item --option @var{value}
++@item -option=@var{value}
++@item -option @var{value}
++@item --o=@var{value}
++@item --o @var{value}
++@item -o=@var{value}
++@item -o @var{value}
++@end table
+
+ All the options and command line arguments you give are processed
+ in sequential order. The order makes a difference when the @option{-x}
+ option is used.
+
+ @table @env
+-@item -help
++@item --help
+ @itemx -h
+ List all options, with brief explanations.
+
+-@item -symbols=@var{file}
++@item --symbols=@var{file}
+ @itemx -s @var{file}
+-Read symbol table from file @var{file}.
++Read symbol table from @var{file}.
+
+-@item -write
++@item --write
+ Enable writing into executable and core files.
+
+-@item -exec=@var{file}
++@item --exec=@var{file}
+ @itemx -e @var{file}
+-Use file @var{file} as the executable file to execute when
++Use @var{file} as the executable file to execute when
+ appropriate, and for examining pure data in conjunction with a core
+ dump.
+
+-@item -se=@var{file}
+-Read symbol table from file @var{file} and use it as the executable
++@item --se=@var{file}
++Read symbol table from @var{file} and use it as the executable
+ file.
+
+-@item -core=@var{file}
++@item --core=@var{file}
+ @itemx -c @var{file}
+-Use file @var{file} as a core dump to examine.
++Use @var{file} as a core dump to examine.
+
+-@item -command=@var{file}
++@item --command=@var{file}
+ @itemx -x @var{file}
+-Execute @value{GDBN} commands from file @var{file}.
++Execute @value{GDBN} commands from @var{file}.
+
++@item --eval-command=@var{command}
+ @item -ex @var{command}
+ Execute given @value{GDBN} @var{command}.
+
+-@item -directory=@var{directory}
++@item --init-eval-command=@var{command}
++@item -iex
++Execute @value{GDBN} @var{command} before loading the inferior.
++
++@item --directory=@var{directory}
+ @itemx -d @var{directory}
+ Add @var{directory} to the path to search for source files.
+
+-@item -nh
++@item --nh
+ Do not execute commands from @file{~/.config/gdb/gdbinit},
+ @file{~/.gdbinit}, @file{~/.config/gdb/gdbearlyinit}, or
+ @file{~/.gdbearlyinit}
+
+-@item -nx
++@item --nx
+ @itemx -n
+ Do not execute commands from any @file{.gdbinit} or
+ @file{.gdbearlyinit} initialization files.
+
+-@item -quiet
++@item --quiet
++@item --silent
+ @itemx -q
+ ``Quiet''. Do not print the introductory and copyright messages. These
+ messages are also suppressed in batch mode.
+
+-@item -batch
++@item --batch
+ Run in batch mode. Exit with status @code{0} after processing all the command
+ files specified with @option{-x} (and @file{.gdbinit}, if not inhibited).
+ Exit with nonzero status if an error occurs in executing the @value{GDBN}
+@@ -47233,11 +47245,71 @@ Program exited normally.
+ (which is ordinarily issued whenever a program running under @value{GDBN} control
+ terminates) is not issued when running in batch mode.
+
+-@item -cd=@var{directory}
++@item --batch-silent
++Run in batch mode, just like @option{--batch}, but totally silent. All @value{GDBN}
++output is supressed (stderr is unaffected). This is much quieter than
++@option{--silent} and would be useless for an interactive session.
++
++This is particularly useful when using targets that give @samp{Loading section}
++messages, for example.
++
++Note that targets that give their output via @value{GDBN}, as opposed to writing
++directly to @code{stdout}, will also be made silent.
++
++@item --args @var{prog} [@var{arglist}]
++Change interpretation of command line so that arguments following this
++option are passed as arguments to the inferior. As an example, take
++the following command:
++
++@smallexample
++gdb ./a.out -q
++@end smallexample
++
++@noindent
++It would start @value{GDBN} with @option{-q}, not printing the introductory message. On
++the other hand, using:
++
++@smallexample
++gdb --args ./a.out -q
++@end smallexample
++
++@noindent
++starts @value{GDBN} with the introductory message, and passes the option to the inferior.
++
++@item --pid=@var{pid}
++Attach @value{GDBN} to an already running program, with the PID @var{pid}.
++
++@item --tui
++Open the terminal user interface.
++
++@item --readnow
++Read all symbols from the given symfile on the first access.
++
++@item --readnever
++Do not read symbol files.
++
++@item --dbx
++Run in DBX compatibility mode.
++
++@item --return-child-result
++@value{GDBN}'s exit code will be the same as the child's exit code.
++
++@item --configuration
++Print details about GDB configuration and then exit.
++
++@item --version
++Print version information and then exit.
++
++@item --cd=@var{directory}
+ Run @value{GDBN} using @var{directory} as its working directory,
+ instead of the current directory.
+
+-@item -fullname
++@item --data-directory=@var{directory}
++@item -D
++Run @value{GDBN} using @var{directory} as its data directory. The data
++directory is where @value{GDBN} searches for its auxiliary files.
++
++@item --fullname
+ @itemx -f
+ Emacs sets this option when it runs @value{GDBN} as a subprocess. It tells
+ @value{GDBN} to output the full file name and line number in a standard,
+@@ -47248,11 +47320,14 @@ and character position separated by colons, and a newline. The
+ Emacs-to-@value{GDBN} interface program uses the two @samp{\032}
+ characters as a signal to display the source code for the frame.
+
+-@item -b @var{bps}
++@item -b @var{baudrate}
+ Set the line speed (baud rate or bits per second) of any serial
+ interface used by @value{GDBN} for remote debugging.
+
+-@item -tty=@var{device}
++@item -l @var{timeout}
++Set timeout, in seconds, for remote debugging.
++
++@item --tty=@var{device}
+ Run using @var{device} for your program's standard input and output.
+ @end table
+ @c man end
diff --git a/gdb-rhbz1350436-type-printers-error.patch b/gdb-rhbz1350436-type-printers-error.patch
index d06e121..3322327 100644
--- a/gdb-rhbz1350436-type-printers-error.patch
+++ b/gdb-rhbz1350436-type-printers-error.patch
@@ -42,22 +42,24 @@ diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.pytho
diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py
--- a/gdb/testsuite/gdb.python/py-typeprint.py
+++ b/gdb/testsuite/gdb.python/py-typeprint.py
-@@ -15,7 +15,7 @@
+@@ -15,8 +15,7 @@
import gdb
+-
-class Recognizer(object):
+class StringRecognizer(object):
def __init__(self):
self.enabled = True
-@@ -30,6 +30,26 @@ class StringTypePrinter(object):
+@@ -32,7 +31,27 @@ class StringTypePrinter(object):
self.enabled = True
def instantiate(self):
- return Recognizer()
+ return StringRecognizer()
+
gdb.type_printers.append(StringTypePrinter())
+
+class OtherRecognizer(object):
diff --git a/gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch b/gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch
deleted file mode 100644
index 1419455..0000000
--- a/gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch
+++ /dev/null
@@ -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));
diff --git a/gdb-rhbz1905996-fix-off-by-one-error-in-ada_fold_name.patch b/gdb-rhbz1905996-fix-off-by-one-error-in-ada_fold_name.patch
deleted file mode 100644
index 5e1bc57..0000000
--- a/gdb-rhbz1905996-fix-off-by-one-error-in-ada_fold_name.patch
+++ /dev/null
@@ -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;
diff --git a/gdb-rhbz1909902-frame_id_p-assert-1.patch b/gdb-rhbz1909902-frame_id_p-assert-1.patch
deleted file mode 100644
index 8dd99a5..0000000
--- a/gdb-rhbz1909902-frame_id_p-assert-1.patch
+++ /dev/null
@@ -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);
- }
- }
-
diff --git a/gdb-rhbz1909902-frame_id_p-assert-2.patch b/gdb-rhbz1909902-frame_id_p-assert-2.patch
deleted file mode 100644
index d804bbe..0000000
--- a/gdb-rhbz1909902-frame_id_p-assert-2.patch
+++ /dev/null
@@ -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
diff --git a/gdb-rhbz1912985-libstdc++-assert.patch b/gdb-rhbz1912985-libstdc++-assert.patch
deleted file mode 100644
index 196e309..0000000
--- a/gdb-rhbz1912985-libstdc++-assert.patch
+++ /dev/null
@@ -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
diff --git a/gdb-rhbz1931344-bfd_seek-elf_read_notes.patch b/gdb-rhbz1931344-bfd_seek-elf_read_notes.patch
deleted file mode 100644
index e212dc6..0000000
--- a/gdb-rhbz1931344-bfd_seek-elf_read_notes.patch
+++ /dev/null
@@ -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;
- }
diff --git a/gdb-rhbz1941080-fix-gdbserver-hang.patch b/gdb-rhbz1941080-fix-gdbserver-hang.patch
deleted file mode 100644
index e639de1..0000000
--- a/gdb-rhbz1941080-fix-gdbserver-hang.patch
+++ /dev/null
@@ -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 15:14:04 -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
- }
-
diff --git a/gdb-rhbz1964167-convert-enum-range_type.patch b/gdb-rhbz1964167-convert-enum-range_type.patch
deleted file mode 100644
index ecf8042..0000000
--- a/gdb-rhbz1964167-convert-enum-range_type.patch
+++ /dev/null
@@ -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"));
diff --git a/gdb-rhbz1964167-fortran-array-slices-at-prompt.patch b/gdb-rhbz1964167-fortran-array-slices-at-prompt.patch
deleted file mode 100644
index 05e5890..0000000
--- a/gdb-rhbz1964167-fortran-array-slices-at-prompt.patch
+++ /dev/null
@@ -1,2660 +0,0 @@
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Kevin Buettner <kevinb@redhat.com>
-Date: Mon, 24 May 2021 22:46:21 -0700
-Subject: gdb-rhbz1964167-fortran-array-slices-at-prompt.patch
-
-;; [fortran] Backport Andrew Burgess's commit for Fortran array
-;; slice support
-
-gdb/fortran: Add support for Fortran array slices at the GDB prompt
-
-This commit brings array slice support to GDB.
-
-WARNING: This patch contains a rather big hack which is limited to
-Fortran arrays, this can be seen in gdbtypes.c and f-lang.c. More
-details on this below.
-
-This patch rewrites two areas of GDB's Fortran support, the code to
-extract an array slice, and the code to print an array.
-
-After this commit a user can, from the GDB prompt, ask for a slice of
-a Fortran array and should get the correct result back. Slices can
-(optionally) have the lower bound, upper bound, and a stride
-specified. Slices can also have a negative stride.
-
-Fortran has the concept of repacking array slices. Within a compiled
-Fortran program if a user passes a non-contiguous array slice to a
-function then the compiler may have to repack the slice, this involves
-copying the elements of the slice to a new area of memory before the
-call, and copying the elements back to the original array after the
-call. Whether repacking occurs will depend on which version of
-Fortran is being used, and what type of function is being called.
-
-This commit adds support for both packed, and unpacked array slicing,
-with the default being unpacked.
-
-With an unpacked array slice, when the user asks for a slice of an
-array GDB creates a new type that accurately describes where the
-elements of the slice can be found within the original array, a
-value of this type is then returned to the user. The address of an
-element within the slice will be equal to the address of an element
-within the original array.
-
-A user can choose to select packed array slices instead using:
-
- (gdb) set fortran repack-array-slices on|off
- (gdb) show fortran repack-array-slices
-
-With packed array slices GDB creates a new type that reflects how the
-elements of the slice would look if they were laid out in contiguous
-memory, allocates a value of this type, and then fetches the elements
-from the original array and places then into the contents buffer of
-the new value.
-
-One benefit of using packed slices over unpacked slices is the memory
-usage, taking a small slice of N elements from a large array will
-require (in GDB) N * ELEMENT_SIZE bytes of memory, while an unpacked
-array will also include all of the "padding" between the
-non-contiguous elements. There are new tests added that highlight
-this difference.
-
-There is also a new debugging flag added with this commit that
-introduces these commands:
-
- (gdb) set debug fortran-array-slicing on|off
- (gdb) show debug fortran-array-slicing
-
-This prints information about how the array slices are being built.
-
-As both the repacking, and the array printing requires GDB to walk
-through a multi-dimensional Fortran array visiting each element, this
-commit adds the file f-array-walk.h, which introduces some
-infrastructure to support this process. This means the array printing
-code in f-valprint.c is significantly reduced.
-
-The only slight issue with this commit is the "rather big hack" that I
-mentioned above. This hack allows us to handle one specific case,
-array slices with negative strides. This is something that I don't
-believe the current GDB value contents model will allow us to
-correctly handle, and rather than rewrite the value contents code
-right now, I'm hoping to slip this hack in as a work around.
-
-The problem is that, as I see it, the current value contents model
-assumes that an object base address will be the lowest address within
-that object, and that the contents of the object start at this base
-address and occupy the TYPE_LENGTH bytes after that.
-
-( We do have the embedded_offset, which is used for C++ sub-classes,
-such that an object can start at some offset from the content buffer,
-however, the assumption that the object then occupies the next
-TYPE_LENGTH bytes is still true within GDB. )
-
-The problem is that Fortran arrays with a negative stride don't follow
-this pattern. In this case the base address of the object points to
-the element with the highest address, the contents of the array then
-start at some offset _before_ the base address, and proceed for one
-element _past_ the base address.
-
-As the stride for such an array would be negative then, in theory the
-TYPE_LENGTH for this type would also be negative. However, in many
-places a value in GDB will degrade to a pointer + length, and the
-length almost always comes from the TYPE_LENGTH.
-
-It is my belief that in order to correctly model this case the value
-content handling of GDB will need to be reworked to split apart the
-value's content buffer (which is a block of memory with a length), and
-the object's in memory base address and length, which could be
-negative.
-
-Things are further complicated because arrays with negative strides
-like this are always dynamic types. When a value has a dynamic type
-and its base address needs resolving we actually store the address of
-the object within the resolved dynamic type, not within the value
-object itself.
-
-In short I don't currently see an easy path to cleanly support this
-situation within GDB. And so I believe that leaves two options,
-either add a work around, or catch cases where the user tries to make
-use of a negative stride, or access an array with a negative stride,
-and throw an error.
-
-This patch currently goes with adding a work around, which is that
-when we resolve a dynamic Fortran array type, if the stride is
-negative, then we adjust the base address to point to the lowest
-address required by the array. The printing and slicing code is aware
-of this adjustment and will correctly slice and print Fortran arrays.
-
-Where this hack will show through to the user is if they ask for the
-address of an array in their program with a negative array stride, the
-address they get from GDB will not match the address that would be
-computed within the Fortran program.
-
-gdb/ChangeLog:
-
- * Makefile.in (HFILES_NO_SRCDIR): Add f-array-walker.h.
- * NEWS: Mention new options.
- * f-array-walker.h: New file.
- * f-lang.c: Include 'gdbcmd.h' and 'f-array-walker.h'.
- (repack_array_slices): New static global.
- (show_repack_array_slices): New function.
- (fortran_array_slicing_debug): New static global.
- (show_fortran_array_slicing_debug): New function.
- (value_f90_subarray): Delete.
- (skip_undetermined_arglist): Delete.
- (class fortran_array_repacker_base_impl): New class.
- (class fortran_lazy_array_repacker_impl): New class.
- (class fortran_array_repacker_impl): New class.
- (fortran_value_subarray): Complete rewrite.
- (set_fortran_list): New static global.
- (show_fortran_list): Likewise.
- (_initialize_f_language): Register new commands.
- (fortran_adjust_dynamic_array_base_address_hack): New function.
- * f-lang.h (fortran_adjust_dynamic_array_base_address_hack):
- Declare.
- * f-valprint.c: Include 'f-array-walker.h'.
- (class fortran_array_printer_impl): New class.
- (f77_print_array_1): Delete.
- (f77_print_array): Delete.
- (fortran_print_array): New.
- (f_value_print_inner): Update to call fortran_print_array.
- * gdbtypes.c: Include 'f-lang.h'.
- (resolve_dynamic_type_internal): Call
- fortran_adjust_dynamic_array_base_address_hack.
-
-gdb/testsuite/ChangeLog:
-
- * gdb.fortran/array-slices-bad.exp: New file.
- * gdb.fortran/array-slices-bad.f90: New file.
- * gdb.fortran/array-slices-sub-slices.exp: New file.
- * gdb.fortran/array-slices-sub-slices.f90: New file.
- * gdb.fortran/array-slices.exp: Rewrite tests.
- * gdb.fortran/array-slices.f90: Rewrite tests.
- * gdb.fortran/vla-sizeof.exp: Correct expected results.
-
-gdb/doc/ChangeLog:
-
- * gdb.texinfo (Debugging Output): Document 'set/show debug
- fortran-array-slicing'.
- (Special Fortran Commands): Document 'set/show fortran
- repack-array-slices'.
-
-diff --git a/gdb/Makefile.in b/gdb/Makefile.in
---- a/gdb/Makefile.in
-+++ b/gdb/Makefile.in
-@@ -1268,6 +1268,7 @@ HFILES_NO_SRCDIR = \
- expression.h \
- extension.h \
- extension-priv.h \
-+ f-array-walker.h \
- f-lang.h \
- fbsd-nat.h \
- fbsd-tdep.h \
-diff --git a/gdb/NEWS b/gdb/NEWS
---- a/gdb/NEWS
-+++ b/gdb/NEWS
-@@ -111,6 +111,19 @@ maintenance print core-file-backed-mappings
- Prints file-backed mappings loaded from a core file's note section.
- Output is expected to be similar to that of "info proc mappings".
-
-+set debug fortran-array-slicing on|off
-+show debug fortran-array-slicing
-+ Print debugging when taking slices of Fortran arrays.
-+
-+set fortran repack-array-slices on|off
-+show fortran repack-array-slices
-+ When taking slices from Fortran arrays and strings, if the slice is
-+ non-contiguous within the original value then, when this option is
-+ on, the new value will be repacked into a single contiguous value.
-+ When this option is off, then the value returned will consist of a
-+ descriptor that describes the slice within the memory of the
-+ original parent value.
-+
- * Changed commands
-
- alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]
-diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
---- a/gdb/doc/gdb.texinfo
-+++ b/gdb/doc/gdb.texinfo
-@@ -16919,6 +16919,29 @@ This command prints the values contained in the Fortran @code{COMMON}
- block whose name is @var{common-name}. With no argument, the names of
- all @code{COMMON} blocks visible at the current program location are
- printed.
-+@cindex arrays slices (Fortran)
-+@kindex set fortran repack-array-slices
-+@kindex show fortran repack-array-slices
-+@item set fortran repack-array-slices [on|off]
-+@item show fortran repack-array-slices
-+When taking a slice from an array, a Fortran compiler can choose to
-+either produce an array descriptor that describes the slice in place,
-+or it may repack the slice, copying the elements of the slice into a
-+new region of memory.
-+
-+When this setting is on, then @value{GDBN} will also repack array
-+slices in some situations. When this setting is off, then
-+@value{GDBN} will create array descriptors for slices that reference
-+the original data in place.
-+
-+@value{GDBN} will never repack an array slice if the data for the
-+slice is contiguous within the original array.
-+
-+@value{GDBN} will always repack string slices if the data for the
-+slice is non-contiguous within the original string as @value{GDBN}
-+does not support printing non-contiguous strings.
-+
-+The default for this setting is @code{off}.
- @end table
-
- @node Pascal
-@@ -26507,6 +26530,16 @@ Show the current state of FreeBSD LWP debugging messages.
- Turns on or off debugging messages from the FreeBSD native target.
- @item show debug fbsd-nat
- Show the current state of FreeBSD native target debugging messages.
-+
-+@item set debug fortran-array-slicing
-+@cindex fortran array slicing debugging info
-+Turns on or off display of @value{GDBN} Fortran array slicing
-+debugging info. The default is off.
-+
-+@item show debug fortran-array-slicing
-+Displays the current state of displaying @value{GDBN} Fortran array
-+slicing debugging info.
-+
- @item set debug frame
- @cindex frame debugging info
- Turns on or off display of @value{GDBN} frame debugging info. The
-diff --git a/gdb/f-array-walker.h b/gdb/f-array-walker.h
-new file mode 100644
---- /dev/null
-+++ b/gdb/f-array-walker.h
-@@ -0,0 +1,265 @@
-+/* Copyright (C) 2020 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ This program is free software; you can redistribute it and/or modify
-+ it under the terms of the GNU General Public License as published by
-+ the Free Software Foundation; either version 3 of the License, or
-+ (at your option) any later version.
-+
-+ This program is distributed in the hope that it will be useful,
-+ but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ GNU General Public License for more details.
-+
-+ You should have received a copy of the GNU General Public License
-+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
-+
-+/* Support classes to wrap up the process of iterating over a
-+ multi-dimensional Fortran array. */
-+
-+#ifndef F_ARRAY_WALKER_H
-+#define F_ARRAY_WALKER_H
-+
-+#include "defs.h"
-+#include "gdbtypes.h"
-+#include "f-lang.h"
-+
-+/* Class for calculating the byte offset for elements within a single
-+ dimension of a Fortran array. */
-+class fortran_array_offset_calculator
-+{
-+public:
-+ /* Create a new offset calculator for TYPE, which is either an array or a
-+ string. */
-+ explicit fortran_array_offset_calculator (struct type *type)
-+ {
-+ /* Validate the type. */
-+ type = check_typedef (type);
-+ if (type->code () != TYPE_CODE_ARRAY
-+ && (type->code () != TYPE_CODE_STRING))
-+ error (_("can only compute offsets for arrays and strings"));
-+
-+ /* Get the range, and extract the bounds. */
-+ struct type *range_type = type->index_type ();
-+ if (!get_discrete_bounds (range_type, &m_lowerbound, &m_upperbound))
-+ error ("unable to read array bounds");
-+
-+ /* Figure out the stride for this array. */
-+ struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (type));
-+ m_stride = type->index_type ()->bounds ()->bit_stride ();
-+ if (m_stride == 0)
-+ m_stride = type_length_units (elt_type);
-+ else
-+ {
-+ struct gdbarch *arch = get_type_arch (elt_type);
-+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
-+ m_stride /= (unit_size * 8);
-+ }
-+ };
-+
-+ /* Get the byte offset for element INDEX within the type we are working
-+ on. There is no bounds checking done on INDEX. If the stride is
-+ negative then we still assume that the base address (for the array
-+ object) points to the element with the lowest memory address, we then
-+ calculate an offset assuming that index 0 will be the element at the
-+ highest address, index 1 the next highest, and so on. This is not
-+ quite how Fortran works in reality; in reality the base address of
-+ the object would point at the element with the highest address, and
-+ we would index backwards from there in the "normal" way, however,
-+ GDB's current value contents model doesn't support having the base
-+ address be near to the end of the value contents, so we currently
-+ adjust the base address of Fortran arrays with negative strides so
-+ their base address points at the lowest memory address. This code
-+ here is part of working around this weirdness. */
-+ LONGEST index_offset (LONGEST index)
-+ {
-+ LONGEST offset;
-+ if (m_stride < 0)
-+ offset = std::abs (m_stride) * (m_upperbound - index);
-+ else
-+ offset = std::abs (m_stride) * (index - m_lowerbound);
-+ return offset;
-+ }
-+
-+private:
-+
-+ /* The stride for the type we are working with. */
-+ LONGEST m_stride;
-+
-+ /* The upper bound for the type we are working with. */
-+ LONGEST m_upperbound;
-+
-+ /* The lower bound for the type we are working with. */
-+ LONGEST m_lowerbound;
-+};
-+
-+/* A base class used by fortran_array_walker. There's no virtual methods
-+ here, sub-classes should just override the functions they want in order
-+ to specialise the behaviour to their needs. The functionality
-+ provided in these default implementations will visit every array
-+ element, but do nothing for each element. */
-+
-+struct fortran_array_walker_base_impl
-+{
-+ /* Called when iterating between the lower and upper bounds of each
-+ dimension of the array. Return true if GDB should continue iterating,
-+ otherwise, return false.
-+
-+ SHOULD_CONTINUE indicates if GDB is going to stop anyway, and should
-+ be taken into consideration when deciding what to return. If
-+ SHOULD_CONTINUE is false then this function must also return false,
-+ the function is still called though in case extra work needs to be
-+ done as part of the stopping process. */
-+ bool continue_walking (bool should_continue)
-+ { return should_continue; }
-+
-+ /* Called when GDB starts iterating over a dimension of the array. The
-+ argument INNER_P is true for the inner most dimension (the dimension
-+ containing the actual elements of the array), and false for more outer
-+ dimensions. For a concrete example of how this function is called
-+ see the comment on process_element below. */
-+ void start_dimension (bool inner_p)
-+ { /* Nothing. */ }
-+
-+ /* Called when GDB finishes iterating over a dimension of the array. The
-+ argument INNER_P is true for the inner most dimension (the dimension
-+ containing the actual elements of the array), and false for more outer
-+ dimensions. LAST_P is true for the last call at a particular
-+ dimension. For a concrete example of how this function is called
-+ see the comment on process_element below. */
-+ void finish_dimension (bool inner_p, bool last_p)
-+ { /* Nothing. */ }
-+
-+ /* Called when processing the inner most dimension of the array, for
-+ every element in the array. ELT_TYPE is the type of the element being
-+ extracted, and ELT_OFF is the offset of the element from the start of
-+ array being walked, and LAST_P is true only when this is the last
-+ element that will be processed in this dimension.
-+
-+ Given this two dimensional array ((1, 2) (3, 4)), the calls to
-+ start_dimension, process_element, and finish_dimension look like this:
-+
-+ start_dimension (false);
-+ start_dimension (true);
-+ process_element (TYPE, OFFSET, false);
-+ process_element (TYPE, OFFSET, true);
-+ finish_dimension (true, false);
-+ start_dimension (true);
-+ process_element (TYPE, OFFSET, false);
-+ process_element (TYPE, OFFSET, true);
-+ finish_dimension (true, true);
-+ finish_dimension (false, true); */
-+ void process_element (struct type *elt_type, LONGEST elt_off, bool last_p)
-+ { /* Nothing. */ }
-+};
-+
-+/* A class to wrap up the process of iterating over a multi-dimensional
-+ Fortran array. IMPL is used to specialise what happens as we walk over
-+ the array. See class FORTRAN_ARRAY_WALKER_BASE_IMPL (above) for the
-+ methods than can be used to customise the array walk. */
-+template<typename Impl>
-+class fortran_array_walker
-+{
-+ /* Ensure that Impl is derived from the required base class. This just
-+ ensures that all of the required API methods are available and have a
-+ sensible default implementation. */
-+ gdb_static_assert ((std::is_base_of<fortran_array_walker_base_impl,Impl>::value));
-+
-+public:
-+ /* Create a new array walker. TYPE is the type of the array being walked
-+ over, and ADDRESS is the base address for the object of TYPE in
-+ memory. All other arguments are forwarded to the constructor of the
-+ template parameter class IMPL. */
-+ template <typename ...Args>
-+ fortran_array_walker (struct type *type, CORE_ADDR address,
-+ Args... args)
-+ : m_type (type),
-+ m_address (address),
-+ m_impl (type, address, args...)
-+ {
-+ m_ndimensions = calc_f77_array_dims (m_type);
-+ }
-+
-+ /* Walk the array. */
-+ void
-+ walk ()
-+ {
-+ walk_1 (1, m_type, 0, false);
-+ }
-+
-+private:
-+ /* The core of the array walking algorithm. NSS is the current
-+ dimension number being processed, TYPE is the type of this dimension,
-+ and OFFSET is the offset (in bytes) for the start of this dimension. */
-+ void
-+ walk_1 (int nss, struct type *type, int offset, bool last_p)
-+ {
-+ /* Extract the range, and get lower and upper bounds. */
-+ struct type *range_type = check_typedef (type)->index_type ();
-+ LONGEST lowerbound, upperbound;
-+ if (!get_discrete_bounds (range_type, &lowerbound, &upperbound))
-+ error ("failed to get range bounds");
-+
-+ /* CALC is used to calculate the offsets for each element in this
-+ dimension. */
-+ fortran_array_offset_calculator calc (type);
-+
-+ m_impl.start_dimension (nss == m_ndimensions);
-+
-+ if (nss != m_ndimensions)
-+ {
-+ /* For dimensions other than the inner most, walk each element and
-+ recurse while peeling off one more dimension of the array. */
-+ for (LONGEST i = lowerbound;
-+ m_impl.continue_walking (i < upperbound + 1);
-+ i++)
-+ {
-+ /* Use the index and the stride to work out a new offset. */
-+ LONGEST new_offset = offset + calc.index_offset (i);
-+
-+ /* Now print the lower dimension. */
-+ struct type *subarray_type
-+ = TYPE_TARGET_TYPE (check_typedef (type));
-+ walk_1 (nss + 1, subarray_type, new_offset, (i == upperbound));
-+ }
-+ }
-+ else
-+ {
-+ /* For the inner most dimension of the array, process each element
-+ within this dimension. */
-+ for (LONGEST i = lowerbound;
-+ m_impl.continue_walking (i < upperbound + 1);
-+ i++)
-+ {
-+ LONGEST elt_off = offset + calc.index_offset (i);
-+
-+ struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (type));
-+ if (is_dynamic_type (elt_type))
-+ {
-+ CORE_ADDR e_address = m_address + elt_off;
-+ elt_type = resolve_dynamic_type (elt_type, {}, e_address);
-+ }
-+
-+ m_impl.process_element (elt_type, elt_off, (i == upperbound));
-+ }
-+ }
-+
-+ m_impl.finish_dimension (nss == m_ndimensions, last_p || nss == 1);
-+ }
-+
-+ /* The array type being processed. */
-+ struct type *m_type;
-+
-+ /* The address in target memory for the object of M_TYPE being
-+ processed. This is required in order to resolve dynamic types. */
-+ CORE_ADDR m_address;
-+
-+ /* An instance of the template specialisation class. */
-+ Impl m_impl;
-+
-+ /* The total number of dimensions in M_TYPE. */
-+ int m_ndimensions;
-+};
-+
-+#endif /* F_ARRAY_WALKER_H */
-diff --git a/gdb/f-lang.c b/gdb/f-lang.c
---- a/gdb/f-lang.c
-+++ b/gdb/f-lang.c
-@@ -36,9 +36,36 @@
- #include "c-lang.h"
- #include "target-float.h"
- #include "gdbarch.h"
-+#include "gdbcmd.h"
-+#include "f-array-walker.h"
-
- #include <math.h>
-
-+/* Whether GDB should repack array slices created by the user. */
-+static bool repack_array_slices = false;
-+
-+/* Implement 'show fortran repack-array-slices'. */
-+static void
-+show_repack_array_slices (struct ui_file *file, int from_tty,
-+ struct cmd_list_element *c, const char *value)
-+{
-+ fprintf_filtered (file, _("Repacking of Fortran array slices is %s.\n"),
-+ value);
-+}
-+
-+/* Debugging of Fortran's array slicing. */
-+static bool fortran_array_slicing_debug = false;
-+
-+/* Implement 'show debug fortran-array-slicing'. */
-+static void
-+show_fortran_array_slicing_debug (struct ui_file *file, int from_tty,
-+ struct cmd_list_element *c,
-+ const char *value)
-+{
-+ fprintf_filtered (file, _("Debugging of Fortran array slicing is %s.\n"),
-+ value);
-+}
-+
- /* Local functions */
-
- /* Return the encoding that should be used for the character type
-@@ -114,57 +141,6 @@ 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, 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);
--
-- *pos += 3;
--
-- 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_flag & RANGE_HIGH_BOUND_DEFAULT)
-- high_bound = range->bounds ()->high.const_val ();
-- 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);
--}
--
--/* 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
-@@ -189,6 +165,145 @@ calc_f77_array_dims (struct type *array_type)
- return ndimen;
- }
-
-+/* A class used by FORTRAN_VALUE_SUBARRAY when repacking Fortran array
-+ slices. This is a base class for two alternative repacking mechanisms,
-+ one for when repacking from a lazy value, and one for repacking from a
-+ non-lazy (already loaded) value. */
-+class fortran_array_repacker_base_impl
-+ : public fortran_array_walker_base_impl
-+{
-+public:
-+ /* Constructor, DEST is the value we are repacking into. */
-+ fortran_array_repacker_base_impl (struct value *dest)
-+ : m_dest (dest),
-+ m_dest_offset (0)
-+ { /* Nothing. */ }
-+
-+ /* When we start processing the inner most dimension, this is where we
-+ will be creating values for each element as we load them and then copy
-+ them into the M_DEST value. Set a value mark so we can free these
-+ temporary values. */
-+ void start_dimension (bool inner_p)
-+ {
-+ if (inner_p)
-+ {
-+ gdb_assert (m_mark == nullptr);
-+ m_mark = value_mark ();
-+ }
-+ }
-+
-+ /* When we finish processing the inner most dimension free all temporary
-+ value that were created. */
-+ void finish_dimension (bool inner_p, bool last_p)
-+ {
-+ if (inner_p)
-+ {
-+ gdb_assert (m_mark != nullptr);
-+ value_free_to_mark (m_mark);
-+ m_mark = nullptr;
-+ }
-+ }
-+
-+protected:
-+ /* Copy the contents of array element ELT into M_DEST at the next
-+ available offset. */
-+ void copy_element_to_dest (struct value *elt)
-+ {
-+ value_contents_copy (m_dest, m_dest_offset, elt, 0,
-+ TYPE_LENGTH (value_type (elt)));
-+ m_dest_offset += TYPE_LENGTH (value_type (elt));
-+ }
-+
-+ /* The value being written to. */
-+ struct value *m_dest;
-+
-+ /* The byte offset in M_DEST at which the next element should be
-+ written. */
-+ LONGEST m_dest_offset;
-+
-+ /* Set with a call to VALUE_MARK, and then reset after calling
-+ VALUE_FREE_TO_MARK. */
-+ struct value *m_mark = nullptr;
-+};
-+
-+/* A class used by FORTRAN_VALUE_SUBARRAY when repacking Fortran array
-+ slices. This class is specialised for repacking an array slice from a
-+ lazy array value, as such it does not require the parent array value to
-+ be loaded into GDB's memory; the parent value could be huge, while the
-+ slice could be tiny. */
-+class fortran_lazy_array_repacker_impl
-+ : public fortran_array_repacker_base_impl
-+{
-+public:
-+ /* Constructor. TYPE is the type of the slice being loaded from the
-+ parent value, so this type will correctly reflect the strides required
-+ to find all of the elements from the parent value. ADDRESS is the
-+ address in target memory of value matching TYPE, and DEST is the value
-+ we are repacking into. */
-+ explicit fortran_lazy_array_repacker_impl (struct type *type,
-+ CORE_ADDR address,
-+ struct value *dest)
-+ : fortran_array_repacker_base_impl (dest),
-+ m_addr (address)
-+ { /* Nothing. */ }
-+
-+ /* Create a lazy value in target memory representing a single element,
-+ then load the element into GDB's memory and copy the contents into the
-+ destination value. */
-+ void process_element (struct type *elt_type, LONGEST elt_off, bool last_p)
-+ {
-+ copy_element_to_dest (value_at_lazy (elt_type, m_addr + elt_off));
-+ }
-+
-+private:
-+ /* The address in target memory where the parent value starts. */
-+ CORE_ADDR m_addr;
-+};
-+
-+/* A class used by FORTRAN_VALUE_SUBARRAY when repacking Fortran array
-+ slices. This class is specialised for repacking an array slice from a
-+ previously loaded (non-lazy) array value, as such it fetches the
-+ element values from the contents of the parent value. */
-+class fortran_array_repacker_impl
-+ : public fortran_array_repacker_base_impl
-+{
-+public:
-+ /* Constructor. TYPE is the type for the array slice within the parent
-+ value, as such it has stride values as required to find the elements
-+ within the original parent value. ADDRESS is the address in target
-+ memory of the value matching TYPE. BASE_OFFSET is the offset from
-+ the start of VAL's content buffer to the start of the object of TYPE,
-+ VAL is the parent object from which we are loading the value, and
-+ DEST is the value into which we are repacking. */
-+ explicit fortran_array_repacker_impl (struct type *type, CORE_ADDR address,
-+ LONGEST base_offset,
-+ struct value *val, struct value *dest)
-+ : fortran_array_repacker_base_impl (dest),
-+ m_base_offset (base_offset),
-+ m_val (val)
-+ {
-+ gdb_assert (!value_lazy (val));
-+ }
-+
-+ /* Extract an element of ELT_TYPE at offset (M_BASE_OFFSET + ELT_OFF)
-+ from the content buffer of M_VAL then copy this extracted value into
-+ the repacked destination value. */
-+ void process_element (struct type *elt_type, LONGEST elt_off, bool last_p)
-+ {
-+ struct value *elt
-+ = value_from_component (m_val, elt_type, (elt_off + m_base_offset));
-+ copy_element_to_dest (elt);
-+ }
-+
-+private:
-+ /* The offset into the content buffer of M_VAL to the start of the slice
-+ being extracted. */
-+ LONGEST m_base_offset;
-+
-+ /* The parent value from which we are extracting a slice. */
-+ struct value *m_val;
-+};
-+
- /* 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.
-@@ -200,51 +315,394 @@ 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)
-+ type *original_array_type = check_typedef (value_type (array));
-+ bool is_string_p = original_array_type->code () == TYPE_CODE_STRING;
-+
-+ /* Perform checks for ARRAY not being available. The somewhat overly
-+ complex logic here is just to keep backward compatibility with the
-+ errors that we used to get before FORTRAN_VALUE_SUBARRAY was
-+ rewritten. Maybe a future task would streamline the error messages we
-+ get here, and update all the expected test results. */
-+ if (exp->elts[*pos].opcode != OP_RANGE)
- {
-- skip_undetermined_arglist (nargs, exp, pos, noside);
-- /* Return the dummy value with the correct type. */
-- return array;
-+ if (type_not_associated (original_array_type))
-+ error (_("no such vector element (vector not associated)"));
-+ else if (type_not_allocated (original_array_type))
-+ error (_("no such vector element (vector not allocated)"));
-+ }
-+ else
-+ {
-+ if (type_not_associated (original_array_type))
-+ error (_("array not associated"));
-+ else if (type_not_allocated (original_array_type))
-+ error (_("array not allocated"));
- }
-
-- LONGEST subscript_array[MAX_FORTRAN_DIMS];
-- int ndimensions = 1;
-- struct type *type = check_typedef (value_type (array));
-+ /* First check that the number of dimensions in the type we are slicing
-+ matches the number of arguments we were passed. */
-+ int ndimensions = calc_f77_array_dims (original_array_type);
-+ if (nargs != ndimensions)
-+ error (_("Wrong number of subscripts"));
-
-- if (nargs > MAX_FORTRAN_DIMS)
-- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
-+ /* This will be initialised below with the type of the elements held in
-+ ARRAY. */
-+ struct type *inner_element_type;
-
-- ndimensions = calc_f77_array_dims (type);
-+ /* Extract the types of each array dimension from the original array
-+ type. We need these available so we can fill in the default upper and
-+ lower bounds if the user requested slice doesn't provide that
-+ information. Additionally unpacking the dimensions like this gives us
-+ the inner element type. */
-+ std::vector<struct type *> dim_types;
-+ {
-+ dim_types.reserve (ndimensions);
-+ struct type *type = original_array_type;
-+ for (int i = 0; i < ndimensions; ++i)
-+ {
-+ dim_types.push_back (type);
-+ type = TYPE_TARGET_TYPE (type);
-+ }
-+ /* TYPE is now the inner element type of the array, we start the new
-+ array slice off as this type, then as we process the requested slice
-+ (from the user) we wrap new types around this to build up the final
-+ slice type. */
-+ inner_element_type = type;
-+ }
-
-- if (nargs != ndimensions)
-- error (_("Wrong number of subscripts"));
-+ /* As we analyse the new slice type we need to understand if the data
-+ being referenced is contiguous. Do decide this we must track the size
-+ of an element at each dimension of the new slice array. Initially the
-+ elements of the inner most dimension of the array are the same inner
-+ most elements as the original ARRAY. */
-+ LONGEST slice_element_size = TYPE_LENGTH (inner_element_type);
-+
-+ /* Start off assuming all data is contiguous, this will be set to false
-+ if access to any dimension results in non-contiguous data. */
-+ bool is_all_contiguous = true;
-+
-+ /* The TOTAL_OFFSET is the distance in bytes from the start of the
-+ original ARRAY to the start of the new slice. This is calculated as
-+ we process the information from the user. */
-+ LONGEST total_offset = 0;
-+
-+ /* A structure representing information about each dimension of the
-+ resulting slice. */
-+ struct slice_dim
-+ {
-+ /* Constructor. */
-+ slice_dim (LONGEST l, LONGEST h, LONGEST s, struct type *idx)
-+ : low (l),
-+ high (h),
-+ stride (s),
-+ index (idx)
-+ { /* Nothing. */ }
-+
-+ /* The low bound for this dimension of the slice. */
-+ LONGEST low;
-+
-+ /* The high bound for this dimension of the slice. */
-+ LONGEST high;
-+
-+ /* The byte stride for this dimension of the slice. */
-+ LONGEST stride;
-+
-+ struct type *index;
-+ };
-+
-+ /* The dimensions of the resulting slice. */
-+ std::vector<slice_dim> slice_dims;
-+
-+ /* Process the incoming arguments. These arguments are in the reverse
-+ order to the array dimensions, that is the first argument refers to
-+ the last array dimension. */
-+ if (fortran_array_slicing_debug)
-+ debug_printf ("Processing array access:\n");
-+ for (int i = 0; i < nargs; ++i)
-+ {
-+ /* For each dimension of the array the user will have either provided
-+ a ranged access with optional lower bound, upper bound, and
-+ stride, or the user will have supplied a single index. */
-+ struct type *dim_type = dim_types[ndimensions - (i + 1)];
-+ if (exp->elts[*pos].opcode == OP_RANGE)
-+ {
-+ int pc = (*pos) + 1;
-+ enum range_flag range_flag = (enum range_flag) exp->elts[pc].longconst;
-+ *pos += 3;
-+
-+ LONGEST low, high, stride;
-+ low = high = stride = 0;
-+
-+ if ((range_flag & RANGE_LOW_BOUND_DEFAULT) == 0)
-+ low = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
-+ else
-+ low = f77_get_lowerbound (dim_type);
-+ if ((range_flag & RANGE_HIGH_BOUND_DEFAULT) == 0)
-+ high = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
-+ else
-+ high = f77_get_upperbound (dim_type);
-+ if ((range_flag & RANGE_HAS_STRIDE) == RANGE_HAS_STRIDE)
-+ stride = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
-+ else
-+ stride = 1;
-+
-+ if (stride == 0)
-+ error (_("stride must not be 0"));
-+
-+ /* Get information about this dimension in the original ARRAY. */
-+ struct type *target_type = TYPE_TARGET_TYPE (dim_type);
-+ struct type *index_type = dim_type->index_type ();
-+ LONGEST lb = f77_get_lowerbound (dim_type);
-+ LONGEST ub = f77_get_upperbound (dim_type);
-+ LONGEST sd = index_type->bit_stride ();
-+ if (sd == 0)
-+ sd = TYPE_LENGTH (target_type) * 8;
-+
-+ if (fortran_array_slicing_debug)
-+ {
-+ debug_printf ("|-> Range access\n");
-+ 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 ("| |-> Accessing:\n");
-+ debug_printf ("| | |-> Low bound: %ld\n",
-+ low);
-+ debug_printf ("| | |-> High bound: %ld\n",
-+ high);
-+ debug_printf ("| | '-> Element stride: %ld\n",
-+ stride);
-+ }
-+
-+ /* Check the user hasn't asked for something invalid. */
-+ if (high > ub || low < lb)
-+ error (_("array subscript out of bounds"));
-+
-+ /* Calculate what this dimension of the new slice array will look
-+ like. OFFSET is the byte offset from the start of the
-+ previous (more outer) dimension to the start of this
-+ dimension. E_COUNT is the number of elements in this
-+ dimension. REMAINDER is the number of elements remaining
-+ between the last included element and the upper bound. For
-+ example an access '1:6:2' will include elements 1, 3, 5 and
-+ have a remainder of 1 (element #6). */
-+ LONGEST lowest = std::min (low, high);
-+ LONGEST offset = (sd / 8) * (lowest - lb);
-+ LONGEST e_count = std::abs (high - low) + 1;
-+ e_count = (e_count + (std::abs (stride) - 1)) / std::abs (stride);
-+ LONGEST new_low = 1;
-+ LONGEST new_high = new_low + e_count - 1;
-+ LONGEST new_stride = (sd * stride) / 8;
-+ LONGEST last_elem = low + ((e_count - 1) * stride);
-+ LONGEST remainder = high - last_elem;
-+ if (low > high)
-+ {
-+ offset += std::abs (remainder) * TYPE_LENGTH (target_type);
-+ if (stride > 0)
-+ error (_("incorrect stride and boundary combination"));
-+ }
-+ else if (stride < 0)
-+ error (_("incorrect stride and boundary combination"));
-+
-+ /* Is the data within this dimension contiguous? It is if the
-+ newly computed stride is the same size as a single element of
-+ this dimension. */
-+ bool is_dim_contiguous = (new_stride == slice_element_size);
-+ is_all_contiguous &= is_dim_contiguous;
-+
-+ 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 ("| '-> Contiguous = %s\n",
-+ (is_dim_contiguous ? "Yes" : "No"));
-+ }
-+
-+ /* Figure out how big (in bytes) an element of this dimension of
-+ the new array slice will be. */
-+ slice_element_size = std::abs (new_stride * e_count);
-+
-+ slice_dims.emplace_back (new_low, new_high, new_stride,
-+ index_type);
-+
-+ /* Update the total offset. */
-+ total_offset += offset;
-+ }
-+ else
-+ {
-+ /* There is a single index for this dimension. */
-+ LONGEST index
-+ = value_as_long (evaluate_subexp_with_coercion (exp, pos, noside));
-+
-+ /* Get information about this dimension in the original ARRAY. */
-+ struct type *target_type = TYPE_TARGET_TYPE (dim_type);
-+ struct type *index_type = dim_type->index_type ();
-+ LONGEST lb = f77_get_lowerbound (dim_type);
-+ LONGEST ub = f77_get_upperbound (dim_type);
-+ LONGEST sd = index_type->bit_stride () / 8;
-+ if (sd == 0)
-+ sd = TYPE_LENGTH (target_type);
-+
-+ if (fortran_array_slicing_debug)
-+ {
-+ debug_printf ("|-> Index access\n");
-+ 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 ("| '-> Accessing:\n");
-+ debug_printf ("| '-> Index: %ld\n", index);
-+ }
-+
-+ /* If the array has actual content then check the index is in
-+ bounds. An array without content (an unbound array) doesn't
-+ have a known upper bound, so don't error check in that
-+ situation. */
-+ if (index < lb
-+ || (dim_type->index_type ()->bounds ()->high.kind () != PROP_UNDEFINED
-+ && index > ub)
-+ || (VALUE_LVAL (array) != lval_memory
-+ && dim_type->index_type ()->bounds ()->high.kind () == PROP_UNDEFINED))
-+ {
-+ if (type_not_associated (dim_type))
-+ error (_("no such vector element (vector not associated)"));
-+ else if (type_not_allocated (dim_type))
-+ error (_("no such vector element (vector not allocated)"));
-+ else
-+ error (_("no such vector element"));
-+ }
-
-- gdb_assert (nargs > 0);
-+ /* Calculate using the type stride, not the target type size. */
-+ LONGEST offset = sd * (index - lb);
-+ total_offset += offset;
-+ }
-+ }
-
-- /* Now that we know we have a legal array subscript expression let us
-- actually find out where this element exists in the array. */
-+ if (noside == EVAL_SKIP)
-+ return array;
-
-- /* Take array indices left to right. */
-- for (int i = 0; i < nargs; i++)
-+ /* Build a type that represents the new array slice in the target memory
-+ of the original ARRAY, this type makes use of strides to correctly
-+ find only those elements that are part of the new slice. */
-+ struct type *array_slice_type = inner_element_type;
-+ for (const auto &d : slice_dims)
- {
-- /* Evaluate each subscript; it must be a legal integer in F77. */
-- value *arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
-+ /* Create the range. */
-+ dynamic_prop p_low, p_high, p_stride;
-+
-+ p_low.set_const_val (d.low);
-+ p_high.set_const_val (d.high);
-+ p_stride.set_const_val (d.stride);
-+
-+ struct type *new_range
-+ = create_range_type_with_stride ((struct type *) NULL,
-+ TYPE_TARGET_TYPE (d.index),
-+ &p_low, &p_high, 0, &p_stride,
-+ true);
-+ array_slice_type
-+ = create_array_type (nullptr, array_slice_type, new_range);
-+ }
-
-- /* Fill in the subscript array. */
-- subscript_array[i] = value_as_long (arg2);
-+ if (fortran_array_slicing_debug)
-+ {
-+ 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 (" |-> Base address: %s\n",
-+ core_addr_to_string (value_address (array)));
-+ debug_printf (" '-> Contiguous = %s\n",
-+ (is_all_contiguous ? "Yes" : "No"));
- }
-
-- /* Internal type of array is arranged right to left. */
-- for (int i = nargs; i > 0; i--)
-+ /* Should we repack this array slice? */
-+ if (!is_all_contiguous && (repack_array_slices || is_string_p))
- {
-- struct type *array_type = check_typedef (value_type (array));
-- LONGEST index = subscript_array[i - 1];
-+ /* Build a type for the repacked slice. */
-+ struct type *repacked_array_type = inner_element_type;
-+ for (const auto &d : slice_dims)
-+ {
-+ /* Create the range. */
-+ dynamic_prop p_low, p_high, p_stride;
-+
-+ p_low.set_const_val (d.low);
-+ p_high.set_const_val (d.high);
-+ p_stride.set_const_val (TYPE_LENGTH (repacked_array_type));
-+
-+ struct type *new_range
-+ = create_range_type_with_stride ((struct type *) NULL,
-+ TYPE_TARGET_TYPE (d.index),
-+ &p_low, &p_high, 0, &p_stride,
-+ true);
-+ repacked_array_type
-+ = create_array_type (nullptr, repacked_array_type, new_range);
-+ }
-
-- array = value_subscripted_rvalue (array, index,
-- f77_get_lowerbound (array_type));
-+ /* Now copy the elements from the original ARRAY into the packed
-+ array value DEST. */
-+ struct value *dest = allocate_value (repacked_array_type);
-+ if (value_lazy (array)
-+ || (total_offset + TYPE_LENGTH (array_slice_type)
-+ > TYPE_LENGTH (check_typedef (value_type (array)))))
-+ {
-+ fortran_array_walker<fortran_lazy_array_repacker_impl> p
-+ (array_slice_type, value_address (array) + total_offset, dest);
-+ p.walk ();
-+ }
-+ else
-+ {
-+ fortran_array_walker<fortran_array_repacker_impl> p
-+ (array_slice_type, value_address (array) + total_offset,
-+ total_offset, array, dest);
-+ p.walk ();
-+ }
-+ array = dest;
-+ }
-+ else
-+ {
-+ if (VALUE_LVAL (array) == lval_memory)
-+ {
-+ /* If the value we're taking a slice from is not yet loaded, or
-+ the requested slice is outside the values content range then
-+ just create a new lazy value pointing at the memory where the
-+ contents we're looking for exist. */
-+ if (value_lazy (array)
-+ || (total_offset + TYPE_LENGTH (array_slice_type)
-+ > TYPE_LENGTH (check_typedef (value_type (array)))))
-+ array = value_at_lazy (array_slice_type,
-+ value_address (array) + total_offset);
-+ else
-+ array = value_from_contents_and_address (array_slice_type,
-+ (value_contents (array)
-+ + total_offset),
-+ (value_address (array)
-+ + total_offset));
-+ }
-+ else if (!value_lazy (array))
-+ {
-+ const void *valaddr = value_contents (array) + total_offset;
-+ array = allocate_value (array_slice_type);
-+ memcpy (value_contents_raw (array), valaddr, TYPE_LENGTH (array_slice_type));
-+ }
-+ else
-+ error (_("cannot subscript arrays that are not in memory"));
- }
-
- return array;
-@@ -1031,11 +1489,50 @@ builtin_f_type (struct gdbarch *gdbarch)
- return (const struct builtin_f_type *) gdbarch_data (gdbarch, f_type_data);
- }
-
-+/* Command-list for the "set/show fortran" prefix command. */
-+static struct cmd_list_element *set_fortran_list;
-+static struct cmd_list_element *show_fortran_list;
-+
- void _initialize_f_language ();
- void
- _initialize_f_language ()
- {
- f_type_data = gdbarch_data_register_post_init (build_fortran_types);
-+
-+ add_basic_prefix_cmd ("fortran", no_class,
-+ _("Prefix command for changing Fortran-specific settings."),
-+ &set_fortran_list, "set fortran ", 0, &setlist);
-+
-+ add_show_prefix_cmd ("fortran", no_class,
-+ _("Generic command for showing Fortran-specific settings."),
-+ &show_fortran_list, "show fortran ", 0, &showlist);
-+
-+ add_setshow_boolean_cmd ("repack-array-slices", class_vars,
-+ &repack_array_slices, _("\
-+Enable or disable repacking of non-contiguous array slices."), _("\
-+Show whether non-contiguous array slices are repacked."), _("\
-+When the user requests a slice of a Fortran array then we can either return\n\
-+a descriptor that describes the array in place (using the original array data\n\
-+in its existing location) or the original data can be repacked (copied) to a\n\
-+new location.\n\
-+\n\
-+When the content of the array slice is contiguous within the original array\n\
-+then the result will never be repacked, but when the data for the new array\n\
-+is non-contiguous within the original array repacking will only be performed\n\
-+when this setting is on."),
-+ NULL,
-+ show_repack_array_slices,
-+ &set_fortran_list, &show_fortran_list);
-+
-+ /* Debug Fortran's array slicing logic. */
-+ add_setshow_boolean_cmd ("fortran-array-slicing", class_maintenance,
-+ &fortran_array_slicing_debug, _("\
-+Set debugging of Fortran array slicing."), _("\
-+Show debugging of Fortran array slicing."), _("\
-+When on, debugging of Fortran array slicing is enabled."),
-+ NULL,
-+ show_fortran_array_slicing_debug,
-+ &setdebuglist, &showdebuglist);
- }
-
- /* See f-lang.h. */
-@@ -1074,3 +1571,56 @@ fortran_preserve_arg_pointer (struct value *arg, struct type *type)
- return value_type (arg);
- return type;
- }
-+
-+/* See f-lang.h. */
-+
-+CORE_ADDR
-+fortran_adjust_dynamic_array_base_address_hack (struct type *type,
-+ CORE_ADDR address)
-+{
-+ gdb_assert (type->code () == TYPE_CODE_ARRAY);
-+
-+ int ndimensions = calc_f77_array_dims (type);
-+ LONGEST total_offset = 0;
-+
-+ /* Walk through each of the dimensions of this array type and figure out
-+ if any of the dimensions are "backwards", that is the base address
-+ for this dimension points to the element at the highest memory
-+ address and the stride is negative. */
-+ struct type *tmp_type = type;
-+ for (int i = 0 ; i < ndimensions; ++i)
-+ {
-+ /* Grab the range for this dimension and extract the lower and upper
-+ bounds. */
-+ tmp_type = check_typedef (tmp_type);
-+ struct type *range_type = tmp_type->index_type ();
-+ LONGEST lowerbound, upperbound, stride;
-+ if (!get_discrete_bounds (range_type, &lowerbound, &upperbound))
-+ error ("failed to get range bounds");
-+
-+ /* Figure out the stride for this dimension. */
-+ struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
-+ stride = tmp_type->index_type ()->bounds ()->bit_stride ();
-+ if (stride == 0)
-+ stride = type_length_units (elt_type);
-+ else
-+ {
-+ struct gdbarch *arch = get_type_arch (elt_type);
-+ int unit_size = gdbarch_addressable_memory_unit_size (arch);
-+ stride /= (unit_size * 8);
-+ }
-+
-+ /* If this dimension is "backward" then figure out the offset
-+ adjustment required to point to the element at the lowest memory
-+ address, and add this to the total offset. */
-+ LONGEST offset = 0;
-+ if (stride < 0 && lowerbound < upperbound)
-+ offset = (upperbound - lowerbound) * stride;
-+ total_offset += offset;
-+ tmp_type = TYPE_TARGET_TYPE (tmp_type);
-+ }
-+
-+ /* Adjust the address of this object and return it. */
-+ address += total_offset;
-+ return address;
-+}
-diff --git a/gdb/f-lang.h b/gdb/f-lang.h
---- a/gdb/f-lang.h
-+++ b/gdb/f-lang.h
-@@ -64,7 +64,6 @@ extern void f77_get_dynamic_array_length (struct type *);
-
- extern int calc_f77_array_dims (struct type *);
-
--
- /* Fortran (F77) types */
-
- struct builtin_f_type
-@@ -122,4 +121,22 @@ extern struct value *fortran_argument_convert (struct value *value,
- extern struct type *fortran_preserve_arg_pointer (struct value *arg,
- struct type *type);
-
-+/* Fortran arrays can have a negative stride. When this happens it is
-+ often the case that the base address for an object is not the lowest
-+ address occupied by that object. For example, an array slice (10:1:-1)
-+ will be encoded with lower bound 1, upper bound 10, a stride of
-+ -ELEMENT_SIZE, and have a base address pointer that points at the
-+ element with the highest address in memory.
-+
-+ This really doesn't play well with our current model of value contents,
-+ but could easily require a significant update in order to be supported
-+ "correctly".
-+
-+ For now, we manually force the base address to be the lowest addressed
-+ element here. Yes, this will break some things, but it fixes other
-+ things. The hope is that it fixes more than it breaks. */
-+
-+extern CORE_ADDR fortran_adjust_dynamic_array_base_address_hack
-+ (struct type *type, CORE_ADDR address);
-+
- #endif /* F_LANG_H */
-diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
---- a/gdb/f-valprint.c
-+++ b/gdb/f-valprint.c
-@@ -35,6 +35,7 @@
- #include "dictionary.h"
- #include "cli/cli-style.h"
- #include "gdbarch.h"
-+#include "f-array-walker.h"
-
- static void f77_get_dynamic_length_of_aggregate (struct type *);
-
-@@ -100,100 +101,103 @@ f77_get_dynamic_length_of_aggregate (struct type *type)
- * TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
- }
-
--/* Actual function which prints out F77 arrays, Valaddr == address in
-- the superior. Address == the address in the inferior. */
-+/* A class used by FORTRAN_PRINT_ARRAY as a specialisation of the array
-+ walking template. This specialisation prints Fortran arrays. */
-
--static void
--f77_print_array_1 (int nss, int ndimensions, struct type *type,
-- const gdb_byte *valaddr,
-- int embedded_offset, CORE_ADDR address,
-- struct ui_file *stream, int recurse,
-- const struct value *val,
-- const struct value_print_options *options,
-- int *elts)
-+class fortran_array_printer_impl : public fortran_array_walker_base_impl
- {
-- struct type *range_type = check_typedef (type)->index_type ();
-- CORE_ADDR addr = address + embedded_offset;
-- LONGEST lowerbound, upperbound;
-- LONGEST i;
--
-- get_discrete_bounds (range_type, &lowerbound, &upperbound);
--
-- if (nss != ndimensions)
-- {
-- struct gdbarch *gdbarch = get_type_arch (type);
-- size_t dim_size = type_length_units (TYPE_TARGET_TYPE (type));
-- int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
-- size_t byte_stride = type->bit_stride () / (unit_size * 8);
-- if (byte_stride == 0)
-- byte_stride = dim_size;
-- size_t offs = 0;
--
-- for (i = lowerbound;
-- (i < upperbound + 1 && (*elts) < options->print_max);
-- i++)
-- {
-- struct value *subarray = value_from_contents_and_address
-- (TYPE_TARGET_TYPE (type), value_contents_for_printing_const (val)
-- + offs, addr + offs);
--
-- 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, ")");
--
-- if (i < upperbound)
-- fprintf_filtered (stream, " ");
-- }
-- if (*elts >= options->print_max && i < upperbound)
-- fprintf_filtered (stream, "...");
-- }
-- else
-- {
-- for (i = lowerbound; i < upperbound + 1 && (*elts) < options->print_max;
-- i++, (*elts)++)
-- {
-- struct value *elt = value_subscript ((struct value *)val, i);
--
-- common_val_print (elt, stream, recurse, options, current_language);
--
-- if (i != upperbound)
-- fprintf_filtered (stream, ", ");
--
-- if ((*elts == options->print_max - 1)
-- && (i != upperbound))
-- fprintf_filtered (stream, "...");
-- }
-- }
--}
-+public:
-+ /* Constructor. TYPE is the array type being printed, ADDRESS is the
-+ address in target memory for the object of TYPE being printed. VAL is
-+ the GDB value (of TYPE) being printed. STREAM is where to print to,
-+ RECOURSE is passed through (and prevents infinite recursion), and
-+ OPTIONS are the printing control options. */
-+ explicit fortran_array_printer_impl (struct type *type,
-+ CORE_ADDR address,
-+ struct value *val,
-+ struct ui_file *stream,
-+ int recurse,
-+ const struct value_print_options *options)
-+ : m_elts (0),
-+ m_val (val),
-+ m_stream (stream),
-+ m_recurse (recurse),
-+ m_options (options)
-+ { /* Nothing. */ }
-+
-+ /* Called while iterating over the array bounds. When SHOULD_CONTINUE is
-+ false then we must return false, as we have reached the end of the
-+ array bounds for this dimension. However, we also return false if we
-+ have printed too many elements (after printing '...'). In all other
-+ cases, return true. */
-+ bool continue_walking (bool should_continue)
-+ {
-+ bool cont = should_continue && (m_elts < m_options->print_max);
-+ if (!cont && should_continue)
-+ fputs_filtered ("...", m_stream);
-+ return cont;
-+ }
-+
-+ /* Called when we start iterating over a dimension. If it's not the
-+ inner most dimension then print an opening '(' character. */
-+ void start_dimension (bool inner_p)
-+ {
-+ fputs_filtered ("(", m_stream);
-+ }
-+
-+ /* Called when we finish processing a batch of items within a dimension
-+ of the array. Depending on whether this is the inner most dimension
-+ or not we print different things, but this is all about adding
-+ separators between elements, and dimensions of the array. */
-+ void finish_dimension (bool inner_p, bool last_p)
-+ {
-+ fputs_filtered (")", m_stream);
-+ if (!last_p)
-+ fputs_filtered (" ", m_stream);
-+ }
-+
-+ /* Called to process an element of ELT_TYPE at offset ELT_OFF from the
-+ start of the parent object. */
-+ void process_element (struct type *elt_type, LONGEST elt_off, bool last_p)
-+ {
-+ /* Extract the element value from the parent value. */
-+ struct value *e_val
-+ = value_from_component (m_val, elt_type, elt_off);
-+ common_val_print (e_val, m_stream, m_recurse, m_options, current_language);
-+ if (!last_p)
-+ fputs_filtered (", ", m_stream);
-+ ++m_elts;
-+ }
-+
-+private:
-+ /* The number of elements printed so far. */
-+ int m_elts;
-+
-+ /* The value from which we are printing elements. */
-+ struct value *m_val;
-+
-+ /* The stream we should print too. */
-+ struct ui_file *m_stream;
-+
-+ /* The recursion counter, passed through when we print each element. */
-+ int m_recurse;
-+
-+ /* The print control options. Gives us the maximum number of elements to
-+ print, and is passed through to each element that we print. */
-+ const struct value_print_options *m_options = nullptr;
-+};
-
--/* This function gets called to print an F77 array, we set up some
-- stuff and then immediately call f77_print_array_1(). */
-+/* This function gets called to print a Fortran array. */
-
- static void
--f77_print_array (struct type *type, const gdb_byte *valaddr,
-- int embedded_offset,
-- CORE_ADDR address, struct ui_file *stream,
-- int recurse,
-- const struct value *val,
-- const struct value_print_options *options)
-+fortran_print_array (struct type *type, CORE_ADDR address,
-+ struct ui_file *stream, int recurse,
-+ const struct value *val,
-+ const struct value_print_options *options)
- {
-- int ndimensions;
-- int elts = 0;
--
-- ndimensions = calc_f77_array_dims (type);
--
-- if (ndimensions > MAX_FORTRAN_DIMS || ndimensions < 0)
-- error (_("\
--Type node corrupt! F77 arrays cannot have %d subscripts (%d Max)"),
-- ndimensions, MAX_FORTRAN_DIMS);
--
-- f77_print_array_1 (1, ndimensions, type, valaddr, embedded_offset,
-- address, stream, recurse, val, options, &elts);
-+ fortran_array_walker<fortran_array_printer_impl> p
-+ (type, address, (struct value *) val, stream, recurse, options);
-+ p.walk ();
- }
- \f
-
-@@ -236,12 +240,7 @@ f_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
-
- case TYPE_CODE_ARRAY:
- if (TYPE_TARGET_TYPE (type)->code () != TYPE_CODE_CHAR)
-- {
-- fprintf_filtered (stream, "(");
-- f77_print_array (type, valaddr, 0,
-- address, stream, recurse, val, options);
-- fprintf_filtered (stream, ")");
-- }
-+ fortran_print_array (type, address, stream, recurse, val, options);
- else
- {
- struct type *ch_type = TYPE_TARGET_TYPE (type);
-diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
---- a/gdb/gdbtypes.c
-+++ b/gdb/gdbtypes.c
-@@ -39,6 +39,7 @@
- #include "dwarf2/loc.h"
- #include "gdbcore.h"
- #include "floatformat.h"
-+#include "f-lang.h"
- #include <algorithm>
-
- /* Initialize BADNESS constants. */
-@@ -2695,7 +2696,16 @@ resolve_dynamic_type_internal (struct type *type,
- prop = TYPE_DATA_LOCATION (resolved_type);
- if (prop != NULL
- && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
-- prop->set_const_val (value);
-+ {
-+ /* Start of Fortran hack. See comment in f-lang.h for what is going
-+ on here.*/
-+ if (current_language->la_language == language_fortran
-+ && resolved_type->code () == TYPE_CODE_ARRAY)
-+ value = fortran_adjust_dynamic_array_base_address_hack (resolved_type,
-+ value);
-+ /* End of Fortran hack. */
-+ prop->set_const_val (value);
-+ }
-
- return resolved_type;
- }
-@@ -3600,9 +3610,11 @@ is_scalar_type_recursive (struct type *t)
- LONGEST low_bound, high_bound;
- struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (t));
-
-- get_discrete_bounds (t->index_type (), &low_bound, &high_bound);
--
-- return high_bound == low_bound && is_scalar_type_recursive (elt_type);
-+ if (get_discrete_bounds (t->index_type (), &low_bound, &high_bound))
-+ return (high_bound == low_bound
-+ && is_scalar_type_recursive (elt_type));
-+ else
-+ return 0;
- }
- /* Are we dealing with a struct with one element? */
- else if (t->code () == TYPE_CODE_STRUCT && t->num_fields () == 1)
-diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.exp b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
-@@ -0,0 +1,69 @@
-+# Copyright 2020 Free Software Foundation, Inc.
-+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/> .
-+
-+# Test invalid element and slice array accesses.
-+
-+if {[skip_fortran_tests]} { return -1 }
-+
-+standard_testfile ".f90"
-+load_lib fortran.exp
-+
-+if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
-+ {debug f90}]} {
-+ return -1
-+}
-+
-+if ![fortran_runto_main] {
-+ untested "could not run to main"
-+ return -1
-+}
-+
-+# gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
-+gdb_breakpoint [gdb_get_line_number "First Breakpoint"]
-+gdb_breakpoint [gdb_get_line_number "Second Breakpoint"]
-+gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
-+
-+gdb_continue_to_breakpoint "First Breakpoint"
-+
-+# Access not yet allocated array.
-+gdb_test "print other" " = <not allocated>"
-+gdb_test "print other(0:4,2:3)" "array not allocated"
-+gdb_test "print other(1,1)" "no such vector element \\(vector not allocated\\)"
-+
-+# Access not yet associated pointer.
-+gdb_test "print pointer2d" " = <not associated>"
-+gdb_test "print pointer2d(1:2,1:2)" "array not associated"
-+gdb_test "print pointer2d(1,1)" "no such vector element \\(vector not associated\\)"
-+
-+gdb_continue_to_breakpoint "Second Breakpoint"
-+
-+# Accessing just outside the arrays.
-+foreach name {array pointer2d other} {
-+ gdb_test "print $name (0:,:)" "array subscript out of bounds"
-+ gdb_test "print $name (:11,:)" "array subscript out of bounds"
-+ gdb_test "print $name (:,0:)" "array subscript out of bounds"
-+ gdb_test "print $name (:,:11)" "array subscript out of bounds"
-+
-+ gdb_test "print $name (0,:)" "no such vector element"
-+ gdb_test "print $name (11,:)" "no such vector element"
-+ gdb_test "print $name (:,0)" "no such vector element"
-+ gdb_test "print $name (:,11)" "no such vector element"
-+}
-+
-+# Stride in the wrong direction.
-+gdb_test "print array (1:10:-1,:)" "incorrect stride and boundary combination"
-+gdb_test "print array (:,1:10:-1)" "incorrect stride and boundary combination"
-+gdb_test "print array (10:1:1,:)" "incorrect stride and boundary combination"
-+gdb_test "print array (:,10:1:1)" "incorrect stride and boundary combination"
-diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.f90 b/gdb/testsuite/gdb.fortran/array-slices-bad.f90
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/array-slices-bad.f90
-@@ -0,0 +1,42 @@
-+! Copyright 2020 Free Software Foundation, Inc.
-+!
-+! This program is free software; you can redistribute it and/or modify
-+! it under the terms of the GNU General Public License as published by
-+! the Free Software Foundation; either version 3 of the License, or
-+! (at your option) any later version.
-+!
-+! This program is distributed in the hope that it will be useful,
-+! but WITHOUT ANY WARRANTY; without even the implied warranty of
-+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+! GNU General Public License for more details.
-+!
-+! You should have received a copy of the GNU General Public License
-+! along with this program. If not, see <http://www.gnu.org/licenses/>.
-+
-+!
-+! Start of test program.
-+!
-+program test
-+
-+ ! Declare variables used in this test.
-+ integer, dimension (1:10,1:10) :: array
-+ integer, allocatable :: other (:, :)
-+ integer, dimension(:,:), pointer :: pointer2d => null()
-+ integer, dimension(1:10,1:10), target :: tarray
-+
-+ print *, "" ! First Breakpoint.
-+
-+ ! Allocate or associate any variables as needed.
-+ allocate (other (1:10, 1:10))
-+ pointer2d => tarray
-+ array = 0
-+
-+ print *, "" ! Second Breakpoint.
-+
-+ ! All done. Deallocate.
-+ deallocate (other)
-+
-+ ! GDB catches this final breakpoint to indicate the end of the test.
-+ print *, "" ! Final Breakpoint.
-+
-+end program test
-diff --git a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
-@@ -0,0 +1,111 @@
-+# Copyright 2020 Free Software Foundation, Inc.
-+
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of the GNU General Public License as published by
-+# the Free Software Foundation; either version 3 of the License, or
-+# (at your option) any later version.
-+#
-+# This program is distributed in the hope that it will be useful,
-+# but WITHOUT ANY WARRANTY; without even the implied warranty of
-+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+# GNU General Public License for more details.
-+#
-+# You should have received a copy of the GNU General Public License
-+# along with this program. If not, see <http://www.gnu.org/licenses/> .
-+
-+# Create a slice of an array, then take a slice of that slice.
-+
-+if {[skip_fortran_tests]} { return -1 }
-+
-+standard_testfile ".f90"
-+load_lib fortran.exp
-+
-+if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
-+ {debug f90}]} {
-+ return -1
-+}
-+
-+if ![fortran_runto_main] {
-+ untested "could not run to main"
-+ return -1
-+}
-+
-+# gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
-+gdb_breakpoint [gdb_get_line_number "Stop Here"]
-+gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
-+
-+# We're going to print some reasonably large arrays.
-+gdb_test_no_output "set print elements unlimited"
-+
-+gdb_continue_to_breakpoint "Stop Here"
-+
-+# Print a slice, capture the convenience variable name created.
-+set cmd "print array (1:10:2, 1:10:2)"
-+gdb_test_multiple $cmd $cmd {
-+ -re "\r\n\\\$(\\d+) = .*\r\n$gdb_prompt $" {
-+ set varname "\$$expect_out(1,string)"
-+ }
-+}
-+
-+# Now check that we can correctly extract all the elements from this
-+# slice.
-+for { set j 1 } { $j < 6 } { incr j } {
-+ for { set i 1 } { $i < 6 } { incr i } {
-+ set val [expr ((($i - 1) * 2) + (($j - 1) * 20)) + 1]
-+ gdb_test "print ${varname} ($i,$j)" " = $val"
-+ }
-+}
-+
-+# Now take a slice of the slice.
-+gdb_test "print ${varname} (3:5, 3:5)" \
-+ " = \\(\\(45, 47, 49\\) \\(65, 67, 69\\) \\(85, 87, 89\\)\\)"
-+
-+# Now take a different slice of a slice.
-+set cmd "print ${varname} (1:5:2, 1:5:2)"
-+gdb_test_multiple $cmd $cmd {
-+ -re "\r\n\\\$(\\d+) = \\(\\(1, 5, 9\\) \\(41, 45, 49\\) \\(81, 85, 89\\)\\)\r\n$gdb_prompt $" {
-+ set varname "\$$expect_out(1,string)"
-+ pass $gdb_test_name
-+ }
-+}
-+
-+# Now take a slice from the slice, of a slice!
-+set cmd "print ${varname} (1:3:2, 1:3:2)"
-+gdb_test_multiple $cmd $cmd {
-+ -re "\r\n\\\$(\\d+) = \\(\\(1, 9\\) \\(81, 89\\)\\)\r\n$gdb_prompt $" {
-+ set varname "\$$expect_out(1,string)"
-+ pass $gdb_test_name
-+ }
-+}
-+
-+# And again!
-+set cmd "print ${varname} (1:2:2, 1:2:2)"
-+gdb_test_multiple $cmd $cmd {
-+ -re "\r\n\\\$(\\d+) = \\(\\(1\\)\\)\r\n$gdb_prompt $" {
-+ set varname "\$$expect_out(1,string)"
-+ pass $gdb_test_name
-+ }
-+}
-+
-+# Test taking a slice with stride of a string. This isn't actually
-+# supported within gfortran (at least), but naturally drops out of how
-+# GDB models arrays and strings in a similar way, so we may as well
-+# test that this is still working.
-+gdb_test "print str (1:26:2)" " = 'acegikmoqsuwy'"
-+gdb_test "print str (26:1:-1)" " = 'zyxwvutsrqponmlkjihgfedcba'"
-+gdb_test "print str (26:1:-2)" " = 'zxvtrpnljhfdb'"
-+
-+# Now test the memory requirements of taking a slice from an array.
-+# The idea is that we shouldn't require more memory to extract a slice
-+# than the size of the slice.
-+#
-+# This will only work if array repacking is turned on, otherwise GDB
-+# will create the slice by generating a new type that sits over the
-+# existing value in memory.
-+gdb_test_no_output "set fortran repack-array-slices on"
-+set element_size [get_integer_valueof "sizeof (array (1,1))" "unknown"]
-+set slice_size [expr $element_size * 4]
-+gdb_test_no_output "set max-value-size $slice_size"
-+gdb_test "print array (1:2, 1:2)" "= \\(\\(1, 2\\) \\(11, 12\\)\\)"
-+gdb_test "print array (2:3, 2:3)" "= \\(\\(12, 13\\) \\(22, 23\\)\\)"
-+gdb_test "print array (2:5:2, 2:5:2)" "= \\(\\(12, 14\\) \\(32, 34\\)\\)"
-diff --git a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.f90 b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.f90
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.f90
-@@ -0,0 +1,96 @@
-+! Copyright 2020 Free Software Foundation, Inc.
-+!
-+! This program is free software; you can redistribute it and/or modify
-+! it under the terms of the GNU General Public License as published by
-+! the Free Software Foundation; either version 3 of the License, or
-+! (at your option) any later version.
-+!
-+! This program is distributed in the hope that it will be useful,
-+! but WITHOUT ANY WARRANTY; without even the implied warranty of
-+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+! GNU General Public License for more details.
-+!
-+! You should have received a copy of the GNU General Public License
-+! along with this program. If not, see <http://www.gnu.org/licenses/>.
-+
-+!
-+! Start of test program.
-+!
-+program test
-+ integer, dimension (1:10,1:11) :: array
-+ character (len=26) :: str = "abcdefghijklmnopqrstuvwxyz"
-+
-+ call fill_array_2d (array)
-+
-+ ! GDB catches this final breakpoint to indicate the end of the test.
-+ print *, "" ! Stop Here
-+
-+ print *, array
-+ print *, str
-+
-+ ! GDB catches this final breakpoint to indicate the end of the test.
-+ print *, "" ! Final Breakpoint.
-+
-+contains
-+
-+ ! Fill a 1D array with a unique positive integer in each element.
-+ subroutine fill_array_1d (array)
-+ integer, dimension (:) :: array
-+ integer :: counter
-+
-+ counter = 1
-+ do j=LBOUND (array, 1), UBOUND (array, 1), 1
-+ array (j) = counter
-+ counter = counter + 1
-+ end do
-+ end subroutine fill_array_1d
-+
-+ ! Fill a 2D array with a unique positive integer in each element.
-+ subroutine fill_array_2d (array)
-+ integer, dimension (:,:) :: array
-+ integer :: counter
-+
-+ counter = 1
-+ do i=LBOUND (array, 2), UBOUND (array, 2), 1
-+ do j=LBOUND (array, 1), UBOUND (array, 1), 1
-+ array (j,i) = counter
-+ counter = counter + 1
-+ end do
-+ end do
-+ end subroutine fill_array_2d
-+
-+ ! Fill a 3D array with a unique positive integer in each element.
-+ subroutine fill_array_3d (array)
-+ integer, dimension (:,:,:) :: array
-+ integer :: counter
-+
-+ counter = 1
-+ do i=LBOUND (array, 3), UBOUND (array, 3), 1
-+ do j=LBOUND (array, 2), UBOUND (array, 2), 1
-+ do k=LBOUND (array, 1), UBOUND (array, 1), 1
-+ array (k, j,i) = counter
-+ counter = counter + 1
-+ end do
-+ end do
-+ end do
-+ end subroutine fill_array_3d
-+
-+ ! Fill a 4D array with a unique positive integer in each element.
-+ subroutine fill_array_4d (array)
-+ integer, dimension (:,:,:,:) :: array
-+ integer :: counter
-+
-+ counter = 1
-+ do i=LBOUND (array, 4), UBOUND (array, 4), 1
-+ do j=LBOUND (array, 3), UBOUND (array, 3), 1
-+ do k=LBOUND (array, 2), UBOUND (array, 2), 1
-+ do l=LBOUND (array, 1), UBOUND (array, 1), 1
-+ array (l, k, j,i) = counter
-+ counter = counter + 1
-+ end do
-+ end do
-+ end do
-+ end do
-+ print *, ""
-+ end subroutine fill_array_4d
-+end program test
-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
-@@ -18,6 +18,21 @@
- # the subroutine. This should exercise GDB's ability to handle
- # different strides for the different dimensions.
-
-+# Testing GDB's ability to print array (and string) slices, including
-+# slices that make use of array strides.
-+#
-+# In the Fortran code various arrays of different ranks are filled
-+# with data, and slices are passed to a series of show functions.
-+#
-+# In this test script we break in each of the show functions, print
-+# the array slice that was passed in, and then move up the stack to
-+# the parent frame and check GDB can manually extract the same slice.
-+#
-+# This test also checks that the size of the array slice passed to the
-+# function (so as extracted and described by the compiler and the
-+# debug information) matches the size of the slice manually extracted
-+# by GDB.
-+
- if {[skip_fortran_tests]} { return -1 }
-
- standard_testfile ".f90"
-@@ -28,57 +43,224 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
- return -1
- }
-
--if ![fortran_runto_main] {
-- untested "could not run to main"
-- return -1
-+# Takes the name of an array slice as used in the test source, and extracts
-+# the base array name. For example: 'array (1,2)' becomes 'array'.
-+proc array_slice_to_var { slice_str } {
-+ regexp "^(?:\\s*\\()*(\[^( \t\]+)" $slice_str matchvar varname
-+ return $varname
- }
-
--gdb_breakpoint "show"
--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\\)\\)" ]
--
--set message_strings \
-- [list \
-- " = 'array'" \
-- " = 'array \\(1:5,1:5\\)'" \
-- " = 'array \\(1:10:2,1:10:2\\)'" \
-- " = 'array \\(1:10:3,1:10:2\\)'" \
-- " = 'array \\(1:10:5,1:10:3\\)'" ]
--
--set i 0
--foreach result $array_contents msg $message_strings {
-- incr i
-- with_test_prefix "test $i" {
-- gdb_continue_to_breakpoint "show"
-- gdb_test "p array" $result
-- gdb_test "p message" "$msg"
-+proc run_test { repack } {
-+ global binfile gdb_prompt
-+
-+ clean_restart ${binfile}
-+
-+ if ![fortran_runto_main] {
-+ untested "could not run to main"
-+ return -1
- }
--}
-
--gdb_continue_to_breakpoint "continue to Final Breakpoint"
-+ gdb_test_no_output "set fortran repack-array-slices $repack"
-+
-+ # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
-+ gdb_breakpoint [gdb_get_line_number "Display Element"]
-+ gdb_breakpoint [gdb_get_line_number "Display String"]
-+ gdb_breakpoint [gdb_get_line_number "Display Array Slice 1D"]
-+ gdb_breakpoint [gdb_get_line_number "Display Array Slice 2D"]
-+ gdb_breakpoint [gdb_get_line_number "Display Array Slice 3D"]
-+ gdb_breakpoint [gdb_get_line_number "Display Array Slice 4D"]
-+ gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
-+
-+ # We're going to print some reasonably large arrays.
-+ gdb_test_no_output "set print elements unlimited"
-+
-+ set found_final_breakpoint false
-+
-+ # We place a limit on the number of tests that can be run, just in
-+ # case something goes wrong, and GDB gets stuck in an loop here.
-+ set test_count 0
-+ while { $test_count < 500 } {
-+ with_test_prefix "test $test_count" {
-+ incr test_count
-+
-+ set found_final_breakpoint false
-+ set expected_result ""
-+ set func_name ""
-+ gdb_test_multiple "continue" "continue" {
-+ -re ".*GDB = (\[^\r\n\]+)\r\n" {
-+ set expected_result $expect_out(1,string)
-+ exp_continue
-+ }
-+ -re "! Display Element" {
-+ set func_name "show_elem"
-+ exp_continue
-+ }
-+ -re "! Display String" {
-+ set func_name "show_str"
-+ exp_continue
-+ }
-+ -re "! Display Array Slice (.)D" {
-+ set func_name "show_$expect_out(1,string)d"
-+ exp_continue
-+ }
-+ -re "! Final Breakpoint" {
-+ set found_final_breakpoint true
-+ exp_continue
-+ }
-+ -re "$gdb_prompt $" {
-+ # We're done.
-+ }
-+ }
-
--# Next test that asking for an array with stride at the CLI gives an
--# error.
--clean_restart ${testfile}
-+ if ($found_final_breakpoint) {
-+ break
-+ }
-
--if ![fortran_runto_main] then {
-- perror "couldn't run to main"
-- continue
-+ # We want to take a look at the line in the previous frame that
-+ # called the current function. I couldn't find a better way of
-+ # doing this than 'up', which will print the line, then 'down'
-+ # again.
-+ #
-+ # I don't want to fill the log with passes for these up/down
-+ # commands, so we don't report any. If something goes wrong then we
-+ # should get a fail from gdb_test_multiple.
-+ set array_slice_name ""
-+ set unique_id ""
-+ array unset replacement_vars
-+ array set replacement_vars {}
-+ gdb_test_multiple "up" "up" {
-+ -re "\r\n\[0-9\]+\[ \t\]+call ${func_name} \\((\[^\r\n\]+)\\)\r\n$gdb_prompt $" {
-+ set array_slice_name $expect_out(1,string)
-+ }
-+ -re "\r\n\[0-9\]+\[ \t\]+call ${func_name} \\((\[^\r\n\]+)\\)\[ \t\]+! VARS=(\[^ \t\r\n\]+)\r\n$gdb_prompt $" {
-+ set array_slice_name $expect_out(1,string)
-+ set unique_id $expect_out(2,string)
-+ }
-+ }
-+ if {$unique_id != ""} {
-+ set str ""
-+ foreach v [split $unique_id ,] {
-+ set val [get_integer_valueof "${v}" "??"\
-+ "get variable '$v' for '$array_slice_name'"]
-+ set replacement_vars($v) $val
-+ if {$str != ""} {
-+ set str "Str,"
-+ }
-+ set str "$str$v=$val"
-+ }
-+ set unique_id " $str"
-+ }
-+ gdb_test_multiple "down" "down" {
-+ -re "\r\n$gdb_prompt $" {
-+ # Don't issue a pass here.
-+ }
-+ }
-+
-+ # Check we have all the information we need to successfully run one
-+ # of these tests.
-+ if { $expected_result == "" } {
-+ perror "failed to extract expected results"
-+ return 0
-+ }
-+ if { $array_slice_name == "" } {
-+ perror "failed to extract array slice name"
-+ return 0
-+ }
-+
-+ # Check GDB can correctly print the array slice that was passed into
-+ # the current frame.
-+ set pattern [string_to_regexp " = $expected_result"]
-+ gdb_test "p array" "$pattern" \
-+ "check value of '$array_slice_name'$unique_id"
-+
-+ # Get the size of the slice.
-+ set size_in_show \
-+ [get_integer_valueof "sizeof (array)" "show_unknown" \
-+ "get sizeof '$array_slice_name'$unique_id in show"]
-+ set addr_in_show \
-+ [get_hexadecimal_valueof "&array" "show_unknown" \
-+ "get address '$array_slice_name'$unique_id in show"]
-+
-+ # Now move into the previous frame, and see if GDB can extract the
-+ # array slice from the original parent object. Again, use of
-+ # gdb_test_multiple to avoid filling the logs with unnecessary
-+ # passes.
-+ gdb_test_multiple "up" "up" {
-+ -re "\r\n$gdb_prompt $" {
-+ # Do nothing.
-+ }
-+ }
-+
-+ # Print the array slice, this will force GDB to manually extract the
-+ # slice from the parent array.
-+ gdb_test "p $array_slice_name" "$pattern" \
-+ "check array slice '$array_slice_name'$unique_id can be extracted"
-+
-+ # Get the size of the slice in the calling frame.
-+ set size_in_parent \
-+ [get_integer_valueof "sizeof ($array_slice_name)" \
-+ "parent_unknown" \
-+ "get sizeof '$array_slice_name'$unique_id in parent"]
-+
-+ # Figure out the start and end addresses of the full array in the
-+ # parent frame.
-+ set full_var_name [array_slice_to_var $array_slice_name]
-+ set start_addr [get_hexadecimal_valueof "&${full_var_name}" \
-+ "start unknown"]
-+ set end_addr [get_hexadecimal_valueof \
-+ "(&${full_var_name}) + sizeof (${full_var_name})" \
-+ "end unknown"]
-+
-+ # The Fortran compiler can choose to either send a descriptor that
-+ # describes the array slice to the subroutine, or it can repack the
-+ # slice into an array section and send that.
-+ #
-+ # We find the address range of the original array in the parent,
-+ # and the address of the slice in the show function, if the
-+ # address of the slice (from show) is in the range of the original
-+ # array then repacking has not occurred, otherwise, the slice is
-+ # outside of the parent, and repacking must have occurred.
-+ #
-+ # The goal here is to compare the sizes of the slice in show with
-+ # the size of the slice extracted by GDB. So we can only compare
-+ # sizes when GDB's repacking setting matches the repacking
-+ # behaviour we got from the compiler.
-+ if { ($addr_in_show < $start_addr || $addr_in_show >= $end_addr) \
-+ == ($repack == "on") } {
-+ gdb_assert {$size_in_show == $size_in_parent} \
-+ "check sizes match"
-+ } elseif { $repack == "off" } {
-+ # GDB's repacking is off (so slices are left unpacked), but
-+ # the compiler did pack this one. As a result we can't
-+ # compare the sizes between the compiler's slice and GDB's
-+ # slice.
-+ verbose -log "slice '$array_slice_name' was repacked, sizes can't be compared"
-+ } else {
-+ # Like the above, but the reverse, GDB's repacking is on, but
-+ # the compiler didn't repack this slice.
-+ verbose -log "slice '$array_slice_name' was not repacked, sizes can't be compared"
-+ }
-+
-+ # If the array name we just tested included variable names, then
-+ # test again with all the variables expanded.
-+ if {$unique_id != ""} {
-+ foreach v [array names replacement_vars] {
-+ set val $replacement_vars($v)
-+ set array_slice_name \
-+ [regsub "\\y${v}\\y" $array_slice_name $val]
-+ }
-+ gdb_test "p $array_slice_name" "$pattern" \
-+ "check array slice '$array_slice_name'$unique_id can be extracted, with variables expanded"
-+ }
-+ }
-+ }
-+
-+ # Ensure we reached the final breakpoint. If more tests have been added
-+ # to the test script, and this starts failing, then the safety 'while'
-+ # loop above might need to be increased.
-+ gdb_assert {$found_final_breakpoint} "ran all tests"
- }
-
--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"
-+foreach_with_prefix repack { on off } {
-+ run_test $repack
-+}
-diff --git a/gdb/testsuite/gdb.fortran/array-slices.f90 b/gdb/testsuite/gdb.fortran/array-slices.f90
---- a/gdb/testsuite/gdb.fortran/array-slices.f90
-+++ b/gdb/testsuite/gdb.fortran/array-slices.f90
-@@ -13,58 +13,368 @@
- ! You should have received a copy of the GNU General Public License
- ! along with this program. If not, see <http://www.gnu.org/licenses/>.
-
--subroutine show (message, array)
-- character (len=*) :: message
-+subroutine show_elem (array)
-+ integer :: array
-+
-+ print *, ""
-+ print *, "Expected GDB Output:"
-+ print *, ""
-+
-+ write(*, fmt="(A)", advance="no") "GDB = "
-+ write(*, fmt="(I0)", advance="no") array
-+ write(*, fmt="(A)", advance="yes") ""
-+
-+ print *, "" ! Display Element
-+end subroutine show_elem
-+
-+subroutine show_str (array)
-+ character (len=*) :: array
-+
-+ print *, ""
-+ print *, "Expected GDB Output:"
-+ print *, ""
-+ write (*, fmt="(A)", advance="no") "GDB = '"
-+ write (*, fmt="(A)", advance="no") array
-+ write (*, fmt="(A)", advance="yes") "'"
-+
-+ print *, "" ! Display String
-+end subroutine show_str
-+
-+subroutine show_1d (array)
-+ integer, dimension (:) :: array
-+
-+ print *, "Array Contents:"
-+ print *, ""
-+
-+ do i=LBOUND (array, 1), UBOUND (array, 1), 1
-+ write(*, fmt="(i4)", advance="no") array (i)
-+ end do
-+
-+ print *, ""
-+ print *, "Expected GDB Output:"
-+ print *, ""
-+
-+ write(*, fmt="(A)", advance="no") "GDB = ("
-+ do i=LBOUND (array, 1), UBOUND (array, 1), 1
-+ if (i > LBOUND (array, 1)) then
-+ write(*, fmt="(A)", advance="no") ", "
-+ end if
-+ write(*, fmt="(I0)", advance="no") array (i)
-+ end do
-+ write(*, fmt="(A)", advance="no") ")"
-+
-+ print *, "" ! Display Array Slice 1D
-+end subroutine show_1d
-+
-+subroutine show_2d (array)
- integer, dimension (:,:) :: array
-
-- print *, message
-+ print *, "Array Contents:"
-+ print *, ""
-+
- do i=LBOUND (array, 2), UBOUND (array, 2), 1
- do j=LBOUND (array, 1), UBOUND (array, 1), 1
- write(*, fmt="(i4)", advance="no") array (j, i)
- end do
- print *, ""
-- end do
-- print *, array
-- print *, ""
-+ end do
-
--end subroutine show
-+ print *, ""
-+ print *, "Expected GDB Output:"
-+ print *, ""
-
--program test
-+ write(*, fmt="(A)", advance="no") "GDB = ("
-+ do i=LBOUND (array, 2), UBOUND (array, 2), 1
-+ if (i > LBOUND (array, 2)) then
-+ write(*, fmt="(A)", advance="no") " "
-+ end if
-+ write(*, fmt="(A)", advance="no") "("
-+ do j=LBOUND (array, 1), UBOUND (array, 1), 1
-+ if (j > LBOUND (array, 1)) then
-+ write(*, fmt="(A)", advance="no") ", "
-+ end if
-+ write(*, fmt="(I0)", advance="no") array (j, i)
-+ end do
-+ write(*, fmt="(A)", advance="no") ")"
-+ end do
-+ write(*, fmt="(A)", advance="yes") ")"
-+
-+ print *, "" ! Display Array Slice 2D
-+end subroutine show_2d
-+
-+subroutine show_3d (array)
-+ integer, dimension (:,:,:) :: array
-+
-+ print *, ""
-+ print *, "Expected GDB Output:"
-+ print *, ""
-+
-+ write(*, fmt="(A)", advance="no") "GDB = ("
-+ do i=LBOUND (array, 3), UBOUND (array, 3), 1
-+ if (i > LBOUND (array, 3)) then
-+ write(*, fmt="(A)", advance="no") " "
-+ end if
-+ write(*, fmt="(A)", advance="no") "("
-+ do j=LBOUND (array, 2), UBOUND (array, 2), 1
-+ if (j > LBOUND (array, 2)) then
-+ write(*, fmt="(A)", advance="no") " "
-+ end if
-+ write(*, fmt="(A)", advance="no") "("
-+ do k=LBOUND (array, 1), UBOUND (array, 1), 1
-+ if (k > LBOUND (array, 1)) then
-+ write(*, fmt="(A)", advance="no") ", "
-+ end if
-+ write(*, fmt="(I0)", advance="no") array (k, j, i)
-+ end do
-+ write(*, fmt="(A)", advance="no") ")"
-+ end do
-+ write(*, fmt="(A)", advance="no") ")"
-+ end do
-+ write(*, fmt="(A)", advance="yes") ")"
-+
-+ print *, "" ! Display Array Slice 3D
-+end subroutine show_3d
-+
-+subroutine show_4d (array)
-+ integer, dimension (:,:,:,:) :: array
-+
-+ print *, ""
-+ print *, "Expected GDB Output:"
-+ print *, ""
-+
-+ write(*, fmt="(A)", advance="no") "GDB = ("
-+ do i=LBOUND (array, 4), UBOUND (array, 4), 1
-+ if (i > LBOUND (array, 4)) then
-+ write(*, fmt="(A)", advance="no") " "
-+ end if
-+ write(*, fmt="(A)", advance="no") "("
-+ do j=LBOUND (array, 3), UBOUND (array, 3), 1
-+ if (j > LBOUND (array, 3)) then
-+ write(*, fmt="(A)", advance="no") " "
-+ end if
-+ write(*, fmt="(A)", advance="no") "("
-+
-+ do k=LBOUND (array, 2), UBOUND (array, 2), 1
-+ if (k > LBOUND (array, 2)) then
-+ write(*, fmt="(A)", advance="no") " "
-+ end if
-+ write(*, fmt="(A)", advance="no") "("
-+ do l=LBOUND (array, 1), UBOUND (array, 1), 1
-+ if (l > LBOUND (array, 1)) then
-+ write(*, fmt="(A)", advance="no") ", "
-+ end if
-+ write(*, fmt="(I0)", advance="no") array (l, k, j, i)
-+ end do
-+ write(*, fmt="(A)", advance="no") ")"
-+ end do
-+ write(*, fmt="(A)", advance="no") ")"
-+ end do
-+ write(*, fmt="(A)", advance="no") ")"
-+ end do
-+ write(*, fmt="(A)", advance="yes") ")"
-+
-+ print *, "" ! Display Array Slice 4D
-+end subroutine show_4d
-
-+!
-+! Start of test program.
-+!
-+program test
- interface
-- subroutine show (message, array)
-- character (len=*) :: message
-+ subroutine show_str (array)
-+ character (len=*) :: array
-+ end subroutine show_str
-+
-+ subroutine show_1d (array)
-+ integer, dimension (:) :: array
-+ end subroutine show_1d
-+
-+ subroutine show_2d (array)
- integer, dimension(:,:) :: array
-- end subroutine show
-+ end subroutine show_2d
-+
-+ subroutine show_3d (array)
-+ integer, dimension(:,:,:) :: array
-+ end subroutine show_3d
-+
-+ subroutine show_4d (array)
-+ integer, dimension(:,:,:,:) :: array
-+ end subroutine show_4d
- end interface
-
-+ ! Declare variables used in this test.
-+ integer, dimension (-10:-1,-10:-2) :: neg_array
- integer, dimension (1:10,1:10) :: array
- integer, allocatable :: other (:, :)
-+ character (len=26) :: str_1 = "abcdefghijklmnopqrstuvwxyz"
-+ integer, dimension (-2:2,-2:2,-2:2) :: array3d
-+ integer, dimension (-3:3,7:10,-3:3,-10:-7) :: array4d
-+ integer, dimension (10:20) :: array1d
-+ integer, dimension(:,:), pointer :: pointer2d => null()
-+ integer, dimension(-1:9,-1:9), target :: tarray
-
-+ ! Allocate or associate any variables as needed.
- allocate (other (-5:4, -2:7))
-+ pointer2d => tarray
-
-- do i=LBOUND (array, 2), UBOUND (array, 2), 1
-- do j=LBOUND (array, 1), UBOUND (array, 1), 1
-- array (j,i) = ((i - 1) * UBOUND (array, 2)) + j
-- end do
-- end do
-+ ! Fill arrays with contents ready for testing.
-+ call fill_array_1d (array1d)
-+
-+ call fill_array_2d (neg_array)
-+ call fill_array_2d (array)
-+ call fill_array_2d (other)
-+ call fill_array_2d (tarray)
-+
-+ call fill_array_3d (array3d)
-+ call fill_array_4d (array4d)
-+
-+ ! The tests. Each call to a show_* function must have a unique set
-+ ! of arguments as GDB uses the arguments are part of the test name
-+ ! string, so duplicate arguments will result in duplicate test
-+ ! names.
-+ !
-+ ! If a show_* line ends with VARS=... where '...' is a comma
-+ ! separated list of variable names, these variables are assumed to
-+ ! be part of the call line, and will be expanded by the test script,
-+ ! for example:
-+ !
-+ ! do x=1,9,1
-+ ! do y=x,10,1
-+ ! call show_1d (some_array (x,y)) ! VARS=x,y
-+ ! end do
-+ ! end do
-+ !
-+ ! In this example the test script will automatically expand 'x' and
-+ ! 'y' in order to better test different aspects of GDB. Do take
-+ ! care, the expansion is not very "smart", so try to avoid clashing
-+ ! with other text on the line, in the example above, avoid variables
-+ ! named 'some' or 'array', as these will likely clash with
-+ ! 'some_array'.
-+ call show_str (str_1)
-+ call show_str (str_1 (1:20))
-+ call show_str (str_1 (10:20))
-
-- do i=LBOUND (other, 2), UBOUND (other, 2), 1
-- do j=LBOUND (other, 1), UBOUND (other, 1), 1
-- other (j,i) = ((i - 1) * UBOUND (other, 2)) + j
-+ call show_elem (array1d (11))
-+ call show_elem (pointer2d (2,3))
-+
-+ call show_1d (array1d)
-+ call show_1d (array1d (13:17))
-+ call show_1d (array1d (17:13:-1))
-+ call show_1d (array (1:5,1))
-+ call show_1d (array4d (1,7,3,:))
-+ call show_1d (pointer2d (-1:3, 2))
-+ call show_1d (pointer2d (-1, 2:4))
-+
-+ ! Enclosing the array slice argument in (...) causess gfortran to
-+ ! repack the array.
-+ call show_1d ((array (1:5,1)))
-+
-+ call show_2d (pointer2d)
-+ call show_2d (array)
-+ call show_2d (array (1:5,1:5))
-+ do i=1,10,2
-+ do j=1,10,3
-+ call show_2d (array (1:10:i,1:10:j)) ! VARS=i,j
-+ call show_2d (array (10:1:-i,1:10:j)) ! VARS=i,j
-+ call show_2d (array (10:1:-i,10:1:-j)) ! VARS=i,j
-+ call show_2d (array (1:10:i,10:1:-j)) ! VARS=i,j
- end do
- end do
-+ call show_2d (array (6:2:-1,3:9))
-+ call show_2d (array (1:10:2, 1:10:2))
-+ call show_2d (other)
-+ call show_2d (other (-5:0, -2:0))
-+ call show_2d (other (-5:4:2, -2:7:3))
-+ call show_2d (neg_array)
-+ call show_2d (neg_array (-10:-3,-8:-4:2))
-+
-+ ! Enclosing the array slice argument in (...) causess gfortran to
-+ ! repack the array.
-+ call show_2d ((array (1:10:3, 1:10:2)))
-+ call show_2d ((neg_array (-10:-3,-8:-4:2)))
-
-- call show ("array", array)
-- call show ("array (1:5,1:5)", array (1:5,1:5))
-- call show ("array (1:10:2,1:10:2)", array (1:10:2,1:10:2))
-- call show ("array (1:10:3,1:10:2)", array (1:10:3,1:10:2))
-- call show ("array (1:10:5,1:10:3)", array (1:10:4,1:10:3))
-+ call show_3d (array3d)
-+ call show_3d (array3d(-1:1,-1:1,-1:1))
-+ call show_3d (array3d(1:-1:-1,1:-1:-1,1:-1:-1))
-
-- call show ("other", other)
-- call show ("other (-5:0, -2:0)", other (-5:0, -2:0))
-- call show ("other (-5:4:2, -2:7:3)", other (-5:4:2, -2:7:3))
-+ ! Enclosing the array slice argument in (...) causess gfortran to
-+ ! repack the array.
-+ call show_3d ((array3d(1:-1:-1,1:-1:-1,1:-1:-1)))
-
-+ call show_4d (array4d)
-+ call show_4d (array4d (-3:0,10:7:-1,0:3,-7:-10:-1))
-+ call show_4d (array4d (3:0:-1, 10:7:-1, :, -7:-10:-1))
-+
-+ ! Enclosing the array slice argument in (...) causess gfortran to
-+ ! repack the array.
-+ call show_4d ((array4d (3:-2:-2, 10:7:-2, :, -7:-10:-1)))
-+
-+ ! All done. Deallocate.
- deallocate (other)
-+
-+ ! GDB catches this final breakpoint to indicate the end of the test.
- print *, "" ! Final Breakpoint.
-+
-+contains
-+
-+ ! Fill a 1D array with a unique positive integer in each element.
-+ subroutine fill_array_1d (array)
-+ integer, dimension (:) :: array
-+ integer :: counter
-+
-+ counter = 1
-+ do j=LBOUND (array, 1), UBOUND (array, 1), 1
-+ array (j) = counter
-+ counter = counter + 1
-+ end do
-+ end subroutine fill_array_1d
-+
-+ ! Fill a 2D array with a unique positive integer in each element.
-+ subroutine fill_array_2d (array)
-+ integer, dimension (:,:) :: array
-+ integer :: counter
-+
-+ counter = 1
-+ do i=LBOUND (array, 2), UBOUND (array, 2), 1
-+ do j=LBOUND (array, 1), UBOUND (array, 1), 1
-+ array (j,i) = counter
-+ counter = counter + 1
-+ end do
-+ end do
-+ end subroutine fill_array_2d
-+
-+ ! Fill a 3D array with a unique positive integer in each element.
-+ subroutine fill_array_3d (array)
-+ integer, dimension (:,:,:) :: array
-+ integer :: counter
-+
-+ counter = 1
-+ do i=LBOUND (array, 3), UBOUND (array, 3), 1
-+ do j=LBOUND (array, 2), UBOUND (array, 2), 1
-+ do k=LBOUND (array, 1), UBOUND (array, 1), 1
-+ array (k, j,i) = counter
-+ counter = counter + 1
-+ end do
-+ end do
-+ end do
-+ end subroutine fill_array_3d
-+
-+ ! Fill a 4D array with a unique positive integer in each element.
-+ subroutine fill_array_4d (array)
-+ integer, dimension (:,:,:,:) :: array
-+ integer :: counter
-+
-+ counter = 1
-+ do i=LBOUND (array, 4), UBOUND (array, 4), 1
-+ do j=LBOUND (array, 3), UBOUND (array, 3), 1
-+ do k=LBOUND (array, 2), UBOUND (array, 2), 1
-+ do l=LBOUND (array, 1), UBOUND (array, 1), 1
-+ array (l, k, j,i) = counter
-+ counter = counter + 1
-+ end do
-+ end do
-+ end do
-+ end do
-+ print *, ""
-+ end subroutine fill_array_4d
- end program test
-diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
---- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
-+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
-@@ -44,7 +44,7 @@ gdb_continue_to_breakpoint "vla1-allocated"
- gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1"
- gdb_test "print sizeof(vla1(3,2,1))" "4" \
- "print sizeof element from allocated vla1"
--gdb_test "print sizeof(vla1(3:4,2,1))" "800" \
-+gdb_test "print sizeof(vla1(3:4,2,1))" "8" \
- "print sizeof sliced vla1"
-
- # Try to access values in undefined pointer to VLA (dangling)
-@@ -61,7 +61,7 @@ gdb_continue_to_breakpoint "pvla-associated"
- gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
- gdb_test "print sizeof(pvla(3,2,1))" "4" \
- "print sizeof element from associated pvla"
--gdb_test "print sizeof(pvla(3:4,2,1))" "800" "print sizeof sliced pvla"
-+gdb_test "print sizeof(pvla(3:4,2,1))" "8" "print sizeof sliced pvla"
-
- gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds-v1"]
- gdb_continue_to_breakpoint "vla1-neg-bounds-v1"
diff --git a/gdb-rhbz1964167-fortran-array-strides-in-expressions.patch b/gdb-rhbz1964167-fortran-array-strides-in-expressions.patch
deleted file mode 100644
index c23ec34..0000000
--- a/gdb-rhbz1964167-fortran-array-strides-in-expressions.patch
+++ /dev/null
@@ -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"
diff --git a/gdb-rhbz1964167-fortran-clean-up-array-expression-evaluation.patch b/gdb-rhbz1964167-fortran-clean-up-array-expression-evaluation.patch
deleted file mode 100644
index 7b62022..0000000
--- a/gdb-rhbz1964167-fortran-clean-up-array-expression-evaluation.patch
+++ /dev/null
@@ -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"));
-
diff --git a/gdb-rhbz1964167-fortran-fix-type-format-mismatch-in-f-lang.c.patch b/gdb-rhbz1964167-fortran-fix-type-format-mismatch-in-f-lang.c.patch
deleted file mode 100644
index 2cdb828..0000000
--- a/gdb-rhbz1964167-fortran-fix-type-format-mismatch-in-f-lang.c.patch
+++ /dev/null
@@ -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",
diff --git a/gdb-rhbz1964167-fortran-range_type-to-range_flag.patch b/gdb-rhbz1964167-fortran-range_type-to-range_flag.patch
deleted file mode 100644
index fed239a..0000000
--- a/gdb-rhbz1964167-fortran-range_type-to-range_flag.patch
+++ /dev/null
@@ -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;
-
diff --git a/gdb-rhbz1964167-fortran-whitespace_array.patch b/gdb-rhbz1964167-fortran-whitespace_array.patch
deleted file mode 100644
index 9021559..0000000
--- a/gdb-rhbz1964167-fortran-whitespace_array.patch
+++ /dev/null
@@ -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 \
diff --git a/gdb-rhbz1964167-move-fortran-expr-handling.patch b/gdb-rhbz1964167-move-fortran-expr-handling.patch
deleted file mode 100644
index b921684..0000000
--- a/gdb-rhbz1964167-move-fortran-expr-handling.patch
+++ /dev/null
@@ -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. */
diff --git a/gdb-rhbz1971096-glibc2.34-1.patch b/gdb-rhbz1971096-glibc2.34-1.patch
deleted file mode 100644
index 6882699..0000000
--- a/gdb-rhbz1971096-glibc2.34-1.patch
+++ /dev/null
@@ -1,307 +0,0 @@
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Kevin Buettner <kevinb@redhat.com>
-Date: Mon, 14 Jun 2021 19:12:06 -0700
-Subject: gdb-rhbz1971096-glibc2.34-1.patch
-
-;; Backport patch fixing gdb on glibc-2.34 machines with regard to attaching
-;; to processes (RH BZ 1971096).
-
-gdb: try to load libthread_db only after reading all shared libraries when attaching / handling a fork child
-
-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 (¤t_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
diff --git a/gdb-rhbz1971096-glibc2.34-2.patch b/gdb-rhbz1971096-glibc2.34-2.patch
deleted file mode 100644
index b9edab9..0000000
--- a/gdb-rhbz1971096-glibc2.34-2.patch
+++ /dev/null
@@ -1,149 +0,0 @@
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Kevin Buettner <kevinb@redhat.com>
-Date: Mon, 14 Jun 2021 19:20:07 -0700
-Subject: gdb-rhbz1971096-glibc2.34-2.patch
-
-;; Backport patch fixing gdb on glibc-2.34 machines w/ regard to
-;; libthread_db initialization.
-
-libthread_db initialization changes related to upcoming glibc-2.34
-
-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. */
diff --git a/gdb-rhbz1971096-glibc2.34-3.patch b/gdb-rhbz1971096-glibc2.34-3.patch
deleted file mode 100644
index 5c56504..0000000
--- a/gdb-rhbz1971096-glibc2.34-3.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Kevin Buettner <kevinb@redhat.com>
-Date: Mon, 14 Jun 2021 19:24:41 -0700
-Subject: gdb-rhbz1971096-glibc2.34-3.patch
-
-;; Backport testsuite patch for matching new libthread_db related output
-;; when testing gdb on glibc-2.34 matchines (RH BZ 1971096).
-
-testsuite/glib-2.34: Match/consume optional libthread_db related output
-
-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
- }
diff --git a/gdb-rhbz1971096-glibc2.34-4.patch b/gdb-rhbz1971096-glibc2.34-4.patch
deleted file mode 100644
index 7ce9be5..0000000
--- a/gdb-rhbz1971096-glibc2.34-4.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Kevin Buettner <kevinb@redhat.com>
-Date: Mon, 14 Jun 2021 19:29:19 -0700
-Subject: gdb-rhbz1971096-glibc2.34-4.patch
-
-;; Backport patch adjusting test gdb.base/print-symbol-loading.exp.
-;; (RH BZ 1971096).
-
-print-symbol-loading.exp: Allow libc symbols to be already loaded
-
-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" {
diff --git a/gdb-rhbz1971096-glibc2.34-5.patch b/gdb-rhbz1971096-glibc2.34-5.patch
deleted file mode 100644
index 911d2bc..0000000
--- a/gdb-rhbz1971096-glibc2.34-5.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Kevin Buettner <kevinb@redhat.com>
-Date: Mon, 14 Jun 2021 19:32:12 -0700
-Subject: gdb-rhbz1971096-glibc2.34-5.patch
-
-;; Backport patch adjusting test gdb.mi/mi-sym-info.exp (RH BZ 1971096).
-
-mi-sym-info.exp: Increase timeout for 114-symbol-info-functions
-
-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
-+ }
- }
- }
- }
diff --git a/gdb-rhbz1976887-field-location-kind.patch b/gdb-rhbz1976887-field-location-kind.patch
new file mode 100644
index 0000000..00f9acc
--- /dev/null
+++ b/gdb-rhbz1976887-field-location-kind.patch
@@ -0,0 +1,30 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Wed, 29 Sep 2021 10:58:50 +0200
+Subject: gdb-rhbz1976887-field-location-kind.patch
+
+;;Backport upstream patch which fixes internal-error: Unexpected
+;;type field location kind (RHBZ 1976887).
+
+gdbtypes.c: Add the case for FIELD_LOC_KIND_DWARF_BLOCK
+
+The case for FIELD_LOC_KIND_DWARF_BLOCK was missing for
+switch TYPE_FIELD_LOC_KIND. Thas caused an internal-error
+under some circumstances.
+
+Fixes bug 28030.
+
+diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
+--- a/gdb/gdbtypes.c
++++ b/gdb/gdbtypes.c
+@@ -5571,6 +5571,10 @@ copy_type_recursive (struct objfile *objfile,
+ xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type,
+ i)));
+ break;
++ case FIELD_LOC_KIND_DWARF_BLOCK:
++ SET_FIELD_DWARF_BLOCK (new_type->field (i),
++ TYPE_FIELD_DWARF_BLOCK (type, i));
++ break;
+ default:
+ internal_error (__FILE__, __LINE__,
+ _("Unexpected type field location kind: %d"),
diff --git a/gdb-rhbz2012976-paper-over-fortran-lex-problems.patch b/gdb-rhbz2012976-paper-over-fortran-lex-problems.patch
new file mode 100644
index 0000000..433f51d
--- /dev/null
+++ b/gdb-rhbz2012976-paper-over-fortran-lex-problems.patch
@@ -0,0 +1,185 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Kevin Buettner <kevinb@redhat.com>
+Date: Mon, 11 Oct 2021 11:22:04 -0700
+Subject: gdb-rhbz2012976-paper-over-fortran-lex-problems.patch
+
+;; Backport gdb.fortran testsuite changes in order to avoid Fortran
+;; lexical analyzer bug.
+
+[gdb/testsuite] Fix FAIL in gdb.mi/mi-var-child-f.exp
+
+When running test-case gdb.mi/mi-var-child-f.exp on openSUSE Tumbleweed
+(with glibc 2.34) I run into:
+...
+(gdb) ^M
+PASS: gdb.mi/mi-var-child-f.exp: mi runto prog_array
+Expecting: ^(-var-create array \* array[^M
+]+)?(\^done,name="array",numchild="[0-9]+",value=".*",type=.*,has_more="0"[^M
+]+[(]gdb[)] ^M
+[ ]*)
+-var-create array * array^M
+&"Attempt to use a type name as an expression.\n"^M
+^error,msg="-var-create: unable to create variable object"^M
+(gdb) ^M
+FAIL: gdb.mi/mi-var-child-f.exp: create local variable array (unexpected output)
+...
+
+The problem is that the name array is used both:
+- as the name for a local variable
+- as the name of a type in glibc, in file malloc/dynarray-skeleton.c, as included
+ by nss/nss_files/files-hosts.c.
+
+Fix this by ignoring the shared lib symbols.
+
+Likewise in a couple of other fortran tests.
+
+Tested on x86_64-linux.
+
+diff --git a/gdb/testsuite/gdb.fortran/allocated.exp b/gdb/testsuite/gdb.fortran/allocated.exp
+--- a/gdb/testsuite/gdb.fortran/allocated.exp
++++ b/gdb/testsuite/gdb.fortran/allocated.exp
+@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ return -1
+ }
+
++# Avoid shared lib symbols.
++gdb_test_no_output "set auto-solib-add off"
++
+ if ![fortran_runto_main] {
+ untested "could not run to main"
+ return -1
+ }
+
++# Avoid libc symbols, in particular the 'array' type.
++gdb_test_no_output "nosharedlibrary"
++
+ # Set all the breakpoints.
+ for { set i 1 } { $i < 6 } { incr i } {
+ gdb_breakpoint [gdb_get_line_number "Breakpoint $i"]
+diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.exp b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
+--- a/gdb/testsuite/gdb.fortran/array-slices-bad.exp
++++ b/gdb/testsuite/gdb.fortran/array-slices-bad.exp
+@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ return -1
+ }
+
++# Avoid shared lib symbols.
++gdb_test_no_output "set auto-solib-add off"
++
+ if ![fortran_runto_main] {
+ untested "could not run to main"
+ return -1
+ }
+
++# Avoid libc symbols, in particular the 'array' type.
++gdb_test_no_output "nosharedlibrary"
++
+ # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
+ gdb_breakpoint [gdb_get_line_number "First Breakpoint"]
+ gdb_breakpoint [gdb_get_line_number "Second Breakpoint"]
+diff --git a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
+--- a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
++++ b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
+@@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ return -1
+ }
+
++# Avoid shared lib symbols.
++gdb_test_no_output "set auto-solib-add off"
++
+ if ![fortran_runto_main] {
+ untested "could not run to main"
+ return -1
+ }
+
++# Avoid libc symbols, in particular the 'array' type.
++gdb_test_no_output "nosharedlibrary"
++
+ # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
+ gdb_breakpoint [gdb_get_line_number "Stop Here"]
+ gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
+diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
+--- a/gdb/testsuite/gdb.fortran/array-slices.exp
++++ b/gdb/testsuite/gdb.fortran/array-slices.exp
+@@ -55,11 +55,17 @@ proc run_test { repack } {
+
+ clean_restart ${binfile}
+
++ # Avoid shared lib symbols.
++ gdb_test_no_output "set auto-solib-add off"
++
+ if ![fortran_runto_main] {
+ untested "could not run to main"
+ return -1
+ }
+
++ # Avoid libc symbols, in particular the 'array' type.
++ gdb_test_no_output "nosharedlibrary"
++
+ gdb_test_no_output "set fortran repack-array-slices $repack"
+
+ # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"]
+diff --git a/gdb/testsuite/gdb.fortran/lbound-ubound.exp b/gdb/testsuite/gdb.fortran/lbound-ubound.exp
+--- a/gdb/testsuite/gdb.fortran/lbound-ubound.exp
++++ b/gdb/testsuite/gdb.fortran/lbound-ubound.exp
+@@ -25,12 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ return -1
+ }
+
++# Avoid shared lib symbols.
++gdb_test_no_output "set auto-solib-add off"
+
+ if ![fortran_runto_main] {
+ untested "could not run to main"
+ return -1
+ }
+
++# Avoid libc symbols, in particular the 'array' type.
++gdb_test_no_output "nosharedlibrary"
++
+ gdb_breakpoint [gdb_get_line_number "Test Breakpoint"]
+ gdb_breakpoint [gdb_get_line_number "Final Breakpoint"]
+
+diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
+--- a/gdb/testsuite/gdb.fortran/subarray.exp
++++ b/gdb/testsuite/gdb.fortran/subarray.exp
+@@ -27,16 +27,17 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
+ return -1
+ }
+
+-gdb_exit
+-gdb_start
+-gdb_reinitialize_dir $srcdir/$subdir
+-gdb_load ${binfile}
++# Avoid shared lib symbols.
++gdb_test_no_output "set auto-solib-add off"
+
+ if ![fortran_runto_main] then {
+ perror "couldn't run to main"
+ continue
+ }
+
++# Avoid libc symbols, in particular the 'array' type.
++gdb_test_no_output "nosharedlibrary"
++
+ # Try to set breakpoint at the last write statement.
+
+ set bp_location [gdb_get_line_number "str(:)"]
+diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
++++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+@@ -36,8 +36,14 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+ mi_gdb_reinitialize_dir $srcdir/$subdir
+ mi_gdb_load ${binfile}
+
++# Avoid shared lib symbols.
++mi_gdb_test "-gdb-set auto-solib-add off" "\\^done"
++
+ mi_runto prog_array
+
++# Avoid libc symbols, in particular the 'array' type.
++mi_gdb_test "nosharedlibrary" ".*\\^done"
++
+ mi_create_varobj "array" "array" "create local variable array"
+
+
diff --git a/gdb-rhbz2022177-dprintf-1.patch b/gdb-rhbz2022177-dprintf-1.patch
new file mode 100644
index 0000000..d912289
--- /dev/null
+++ b/gdb-rhbz2022177-dprintf-1.patch
@@ -0,0 +1,315 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Kevin Buettner <kevinb@redhat.com>
+Date: Wed, 10 Nov 2021 18:52:22 -0700
+Subject: gdb-rhbz2022177-dprintf-1.patch
+
+;; Backport fix for dprintf bug (RH BZ 2022177).
+
+Fix PR 28308 - dprintf breakpoints not working when run from script
+
+This commit fixes Bug 28308, titled "Strange interactions with
+dprintf and break/commands":
+
+Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28308
+
+Since creating that bug report, I've found a somewhat simpler way of
+reproducing the problem. I've encapsulated it into the GDB test case
+which I've created along with this bug fix. The name of the new test
+is gdb.base/dprintf-execution-x-script.exp, I'll demonstrate the
+problem using this test case, though for brevity, I've placed all
+relevant files in the same directory and have renamed the files to all
+start with 'dp-bug' instead of 'dprintf-execution-x-script'.
+
+The script file, named dp-bug.gdb, consists of the following commands:
+
+dprintf increment, "dprintf in increment(), vi=%d\n", vi
+break inc_vi
+commands
+ continue
+end
+run
+
+Note that the final command in this script is 'run'. When 'run' is
+instead issued interactively, the bug does not occur. So, let's look
+at the interactive case first in order to see the correct/expected
+output:
+
+$ gdb -q -x dp-bug.gdb dp-bug
+... eliding buggy output which I'll discuss later ...
+(gdb) run
+Starting program: /mesquite2/sourceware-git/f34-master/bld/gdb/tmp/dp-bug
+vi=0
+dprintf in increment(), vi=0
+
+Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26
+26 in dprintf-execution-x-script.c
+vi=1
+dprintf in increment(), vi=1
+
+Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26
+26 in dprintf-execution-x-script.c
+vi=2
+dprintf in increment(), vi=2
+
+Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26
+26 in dprintf-execution-x-script.c
+vi=3
+[Inferior 1 (process 1539210) exited normally]
+
+In this run, in which 'run' was issued from the gdb prompt (instead
+of at the end of the script), there are three dprintf messages along
+with three 'Breakpoint 2' messages. This is the correct output.
+
+Now let's look at the output that I snipped above; this is the output
+when 'run' is issued from the script loaded via GDB's -x switch:
+
+$ gdb -q -x dp-bug.gdb dp-bug
+Reading symbols from dp-bug...
+Dprintf 1 at 0x40116e: file dprintf-execution-x-script.c, line 38.
+Breakpoint 2 at 0x40113a: file dprintf-execution-x-script.c, line 26.
+vi=0
+dprintf in increment(), vi=0
+
+Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26
+26 dprintf-execution-x-script.c: No such file or directory.
+vi=1
+
+Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26
+26 in dprintf-execution-x-script.c
+vi=2
+
+Breakpoint 2, inc_vi () at dprintf-execution-x-script.c:26
+26 in dprintf-execution-x-script.c
+vi=3
+[Inferior 1 (process 1539175) exited normally]
+
+In the output shown above, only the first dprintf message is printed.
+The 2nd and 3rd dprintf messages are missing! However, all three
+'Breakpoint 2...' messages are still printed.
+
+Why does this happen?
+
+bpstat_do_actions_1() in gdb/breakpoint.c contains the following
+comment and code near the start of the function:
+
+ /* Avoid endless recursion if a `source' command is contained
+ in bs->commands. */
+ if (executing_breakpoint_commands)
+ return 0;
+
+ scoped_restore save_executing
+ = make_scoped_restore (&executing_breakpoint_commands, 1);
+
+Also, as described by this comment prior to the 'async' field
+in 'struct ui' in top.h, the main UI starts off in sync mode
+when processing command line arguments:
+
+ /* True if the UI is in async mode, false if in sync mode. If in
+ sync mode, a synchronous execution command (e.g, "next") does not
+ return until the command is finished. If in async mode, then
+ running a synchronous command returns right after resuming the
+ target. Waiting for the command's completion is later done on
+ the top event loop. For the main UI, this starts out disabled,
+ until all the explicit command line arguments (e.g., `gdb -ex
+ "start" -ex "next"') are processed. */
+
+This combination of things, the state of the static global
+'executing_breakpoint_commands' plus the state of the async
+field in the main UI causes this behavior.
+
+This is a backtrace after hitting the dprintf breakpoint for
+the second time when doing 'run' from the script file, i.e.
+non-interactively:
+
+Thread 1 "gdb" hit Breakpoint 3, bpstat_do_actions_1 (bsp=0x7fffffffc2b8)
+ at /ironwood1/sourceware-git/f34-master/bld/../../worktree-master/gdb/breakpoint.c:4431
+4431 if (executing_breakpoint_commands)
+
+ #0 bpstat_do_actions_1 (bsp=0x7fffffffc2b8)
+ at gdb/breakpoint.c:4431
+ #1 0x00000000004d8bc6 in dprintf_after_condition_true (bs=0x1538090)
+ at gdb/breakpoint.c:13048
+ #2 0x00000000004c5caa in bpstat_stop_status (aspace=0x116dbc0, bp_addr=0x40116e, thread=0x137f450, ws=0x7fffffffc718,
+ stop_chain=0x1538090) at gdb/breakpoint.c:5498
+ #3 0x0000000000768d98 in handle_signal_stop (ecs=0x7fffffffc6f0)
+ at gdb/infrun.c:6172
+ #4 0x00000000007678d3 in handle_inferior_event (ecs=0x7fffffffc6f0)
+ at gdb/infrun.c:5662
+ #5 0x0000000000763cd5 in fetch_inferior_event ()
+ at gdb/infrun.c:4060
+ #6 0x0000000000746d7d in inferior_event_handler (event_type=INF_REG_EVENT)
+ at gdb/inf-loop.c:41
+ #7 0x00000000007a702f in handle_target_event (error=0, client_data=0x0)
+ at gdb/linux-nat.c:4207
+ #8 0x0000000000b8cd6e in gdb_wait_for_event (block=block@entry=0)
+ at gdbsupport/event-loop.cc:701
+ #9 0x0000000000b8d032 in gdb_wait_for_event (block=0)
+ at gdbsupport/event-loop.cc:597
+ #10 gdb_do_one_event () at gdbsupport/event-loop.cc:212
+ #11 0x00000000009d19b6 in wait_sync_command_done ()
+ at gdb/top.c:528
+ #12 0x00000000009d1a3f in maybe_wait_sync_command_done (was_sync=0)
+ at gdb/top.c:545
+ #13 0x00000000009d2033 in execute_command (p=0x7fffffffcb18 "", from_tty=0)
+ at gdb/top.c:676
+ #14 0x0000000000560d5b in execute_control_command_1 (cmd=0x13b9bb0, from_tty=0)
+ at gdb/cli/cli-script.c:547
+ #15 0x000000000056134a in execute_control_command (cmd=0x13b9bb0, from_tty=0)
+ at gdb/cli/cli-script.c:717
+ #16 0x00000000004c3bbe in bpstat_do_actions_1 (bsp=0x137f530)
+ at gdb/breakpoint.c:4469
+ #17 0x00000000004c3d40 in bpstat_do_actions ()
+ at gdb/breakpoint.c:4533
+ #18 0x00000000006a473a in command_handler (command=0x1399ad0 "run")
+ at gdb/event-top.c:624
+ #19 0x00000000009d182e in read_command_file (stream=0x113e540)
+ at gdb/top.c:443
+ #20 0x0000000000563697 in script_from_file (stream=0x113e540, file=0x13bb0b0 "dp-bug.gdb")
+ at gdb/cli/cli-script.c:1642
+ #21 0x00000000006abd63 in source_gdb_script (extlang=0xc44e80 <extension_language_gdb>, stream=0x113e540,
+ file=0x13bb0b0 "dp-bug.gdb") at gdb/extension.c:188
+ #22 0x0000000000544400 in source_script_from_stream (stream=0x113e540, file=0x7fffffffd91a "dp-bug.gdb",
+ file_to_open=0x13bb0b0 "dp-bug.gdb")
+ at gdb/cli/cli-cmds.c:692
+ #23 0x0000000000544557 in source_script_with_search (file=0x7fffffffd91a "dp-bug.gdb", from_tty=1, search_path=0)
+ at gdb/cli/cli-cmds.c:750
+ #24 0x00000000005445cf in source_script (file=0x7fffffffd91a "dp-bug.gdb", from_tty=1)
+ at gdb/cli/cli-cmds.c:759
+ #25 0x00000000007cf6d9 in catch_command_errors (command=0x5445aa <source_script(char const*, int)>,
+ arg=0x7fffffffd91a "dp-bug.gdb", from_tty=1, do_bp_actions=false)
+ at gdb/main.c:523
+ #26 0x00000000007cf85d in execute_cmdargs (cmdarg_vec=0x7fffffffd1b0, file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND,
+ ret=0x7fffffffd18c) at gdb/main.c:615
+ #27 0x00000000007d0c8e in captured_main_1 (context=0x7fffffffd3f0)
+ at gdb/main.c:1322
+ #28 0x00000000007d0eba in captured_main (data=0x7fffffffd3f0)
+ at gdb/main.c:1343
+ #29 0x00000000007d0f25 in gdb_main (args=0x7fffffffd3f0)
+ at gdb/main.c:1368
+ #30 0x00000000004186dd in main (argc=5, argv=0x7fffffffd508)
+ at gdb/gdb.c:32
+
+There are two frames for bpstat_do_actions_1(), one at frame #16 and
+the other at frame #0. The one at frame #16 is processing the actions
+for Breakpoint 2, which is a 'continue'. The one at frame #0 is attempting
+to process the dprintf breakpoint action. However, at this point,
+the value of 'executing_breakpoint_commands' is 1, forcing an early
+return, i.e. prior to executing the command(s) associated with the dprintf
+breakpoint.
+
+For the sake of comparison, this is what the stack looks like when hitting
+the dprintf breakpoint for the second time when issuing the 'run'
+command from the GDB prompt.
+
+Thread 1 "gdb" hit Breakpoint 3, bpstat_do_actions_1 (bsp=0x7fffffffccd8)
+ at /ironwood1/sourceware-git/f34-master/bld/../../worktree-master/gdb/breakpoint.c:4431
+4431 if (executing_breakpoint_commands)
+
+ #0 bpstat_do_actions_1 (bsp=0x7fffffffccd8)
+ at gdb/breakpoint.c:4431
+ #1 0x00000000004d8bc6 in dprintf_after_condition_true (bs=0x16b0290)
+ at gdb/breakpoint.c:13048
+ #2 0x00000000004c5caa in bpstat_stop_status (aspace=0x116dbc0, bp_addr=0x40116e, thread=0x13f0e60, ws=0x7fffffffd138,
+ stop_chain=0x16b0290) at gdb/breakpoint.c:5498
+ #3 0x0000000000768d98 in handle_signal_stop (ecs=0x7fffffffd110)
+ at gdb/infrun.c:6172
+ #4 0x00000000007678d3 in handle_inferior_event (ecs=0x7fffffffd110)
+ at gdb/infrun.c:5662
+ #5 0x0000000000763cd5 in fetch_inferior_event ()
+ at gdb/infrun.c:4060
+ #6 0x0000000000746d7d in inferior_event_handler (event_type=INF_REG_EVENT)
+ at gdb/inf-loop.c:41
+ #7 0x00000000007a702f in handle_target_event (error=0, client_data=0x0)
+ at gdb/linux-nat.c:4207
+ #8 0x0000000000b8cd6e in gdb_wait_for_event (block=block@entry=0)
+ at gdbsupport/event-loop.cc:701
+ #9 0x0000000000b8d032 in gdb_wait_for_event (block=0)
+ at gdbsupport/event-loop.cc:597
+ #10 gdb_do_one_event () at gdbsupport/event-loop.cc:212
+ #11 0x00000000007cf512 in start_event_loop ()
+ at gdb/main.c:421
+ #12 0x00000000007cf631 in captured_command_loop ()
+ at gdb/main.c:481
+ #13 0x00000000007d0ebf in captured_main (data=0x7fffffffd3f0)
+ at gdb/main.c:1353
+ #14 0x00000000007d0f25 in gdb_main (args=0x7fffffffd3f0)
+ at gdb/main.c:1368
+ #15 0x00000000004186dd in main (argc=5, argv=0x7fffffffd508)
+ at gdb/gdb.c:32
+
+This relatively short backtrace is due to the current UI's async field
+being set to 1.
+
+Yet another thing to be aware of regarding this problem is the
+difference in the way that commands associated to dprintf breakpoints
+versus regular breakpoints are handled. While they both use a command
+list associated with the breakpoint, regular breakpoints will place
+the commands to be run on the bpstat chain constructed in
+bp_stop_status(). These commands are run later on. For dprintf
+breakpoints, commands are run via the 'after_condition_true' function
+pointer directly from bpstat_stop_status(). (The 'commands' field in
+the bpstat is cleared in dprintf_after_condition_true(). This
+prevents the dprintf commands from being run again later on when other
+commands on the bpstat chain are processed.)
+
+Another thing that I noticed is that dprintf breakpoints are the only
+type of breakpoint which use 'after_condition_true'. This suggests
+that one possible way of fixing this problem, that of making dprintf
+breakpoints work more like regular breakpoints, probably won't work.
+(I must admit, however, that my understanding of this code isn't
+complete enough to say why. I'll trust that whoever implemented it
+had a good reason for doing it this way.)
+
+The comment referenced earlier regarding 'executing_breakpoint_commands'
+states that the reason for checking this variable is to avoid
+potential endless recursion when a 'source' command appears in
+bs->commands. We know that a dprintf command is constrained to either
+1) execution of a GDB printf command, 2) an inferior function call of
+a printf-like function, or 3) execution of an agent-printf command.
+Therefore, infinite recursion due to a 'source' command cannot happen
+when executing commands upon hitting a dprintf breakpoint.
+
+I chose to fix this problem by having dprintf_after_condition_true()
+directly call execute_control_commands(). This means that it no
+longer attempts to go through bpstat_do_actions_1() avoiding the
+infinite recursion check for potential 'source' commands on the
+command chain. I think it simplifies this code a little bit too, a
+definite bonus.
+
+Summary:
+
+ * breakpoint.c (dprintf_after_condition_true): Don't call
+ bpstat_do_actions_1(). Call execute_control_commands()
+ instead.
+
+diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
+--- a/gdb/breakpoint.c
++++ b/gdb/breakpoint.c
+@@ -13043,9 +13043,6 @@ dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp)
+ static void
+ dprintf_after_condition_true (struct bpstats *bs)
+ {
+- struct bpstats tmp_bs;
+- struct bpstats *tmp_bs_p = &tmp_bs;
+-
+ /* dprintf's never cause a stop. This wasn't set in the
+ check_status hook instead because that would make the dprintf's
+ condition not be evaluated. */
+@@ -13056,14 +13053,9 @@ dprintf_after_condition_true (struct bpstats *bs)
+ bpstat_do_actions, if a breakpoint that causes a stop happens to
+ be set at same address as this dprintf, or even if running the
+ commands here throws. */
+- tmp_bs.commands = bs->commands;
+- bs->commands = NULL;
+-
+- bpstat_do_actions_1 (&tmp_bs_p);
+-
+- /* 'tmp_bs.commands' will usually be NULL by now, but
+- bpstat_do_actions_1 may return early without processing the whole
+- list. */
++ counted_command_line cmds = std::move (bs->commands);
++ gdb_assert (cmds != nullptr);
++ execute_control_commands (cmds.get (), 0);
+ }
+
+ /* The breakpoint_ops structure to be used on static tracepoints with
diff --git a/gdb-rhbz2022177-dprintf-2.patch b/gdb-rhbz2022177-dprintf-2.patch
new file mode 100644
index 0000000..44bcd87
--- /dev/null
+++ b/gdb-rhbz2022177-dprintf-2.patch
@@ -0,0 +1,194 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: Kevin Buettner <kevinb@redhat.com>
+Date: Wed, 10 Nov 2021 18:55:43 -0700
+Subject: gdb-rhbz2022177-dprintf-2.patch
+
+;; Backport test case for dprintf bug (RH BZ 2022177).
+
+Test case for Bug 28308
+
+The purpose of this test is described in the comments in
+dprintf-execution-x-script.exp.
+
+Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28308
+
+The name of this new test was based on that of an existing test,
+bp-cmds-execution-x-script.exp. I started off by copying that test,
+adding to it, and then rewriting almost all of it. It's different
+enough that I decided that listing the copyright year as 2021
+was sufficient.
+
+diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.c b/gdb/testsuite/gdb.base/dprintf-execution-x-script.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.c
+@@ -0,0 +1,53 @@
++/* This testcase is part of GDB, the GNU debugger.
++
++ Copyright 2021 Free Software Foundation, Inc.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include <stdlib.h>
++#include <stdio.h>
++
++volatile int vi = 0;
++
++void
++inc_vi ()
++{
++ vi++;
++}
++
++void
++print_vi ()
++{
++ printf ("vi=%d\n", vi);
++}
++
++void
++increment ()
++{
++ inc_vi ();
++}
++
++int
++main (int argc, char **argv)
++{
++ print_vi ();
++ increment ();
++ print_vi ();
++ increment ();
++ print_vi ();
++ increment ();
++ print_vi ();
++
++ exit (0);
++}
+diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp
+@@ -0,0 +1,85 @@
++# Copyright 2021 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++# Test that commands in a GDB script file run via GDB's -x flag work
++# as expected. Specifically, the script creates a dprintf breakpoint
++# as well as a normal breakpoint that has "continue" in its command
++# list, and then does "run". Correct output from GDB is checked as
++# part of this test.
++
++# Bail out if the target can't use the 'run' command.
++if ![target_can_use_run_cmd] {
++ return 0
++}
++
++standard_testfile
++
++if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
++ return -1
++}
++
++# This is the name of the GDB script to load.
++set x_file ${srcdir}/${subdir}/$testfile.gdb
++
++# Create context in which the global, GDBFLAGS, will be restored at
++# the end of the block. All commands run within the block are
++# actually run in the outer context. (This is why 'res' is available
++# outside of the save_vars block.)
++save_vars { GDBFLAGS } {
++ # Set flags with which to start GDB.
++ append GDBFLAGS " -ex \"set height unlimited\""
++ append GDBFLAGS " -x \"$x_file\""
++ append GDBFLAGS " --args \"$binfile\""
++
++ # Start GDB with above flags.
++ set res [gdb_spawn]
++}
++
++set test "load and run script with -x"
++if { $res != 0} {
++ fail $test
++ return -1
++}
++
++# The script loaded via -x contains a run command; while running, GDB
++# is expected to print three messages from dprintf breakpoints along
++# with three interspersed messages from an ordinary breakpoint (which
++# was set up with a continue command). Set up pattern D to match
++# output from hitting the dprintf breakpoint and B for the ordinary
++# breakpoint. Then set PAT to contain the entire pattern of expected
++# output from the interspersed dprintf and ordinary breakpoints along
++# with some (additional) expected output from the dprintf breakpoints,
++# i.e. 0, 1, and 2.
++set d "dprintf in increment.., vi="
++set b "Breakpoint ., inc_vi"
++set pat "${d}0.*?$b.*?${d}1.*?$b.*?${d}2.*?$b.*?"
++
++proc do_test {cmd test} {
++ gdb_test $cmd "$::pat$::inferior_exited_re normally.*" $test
++}
++
++# Check output from running script with -x
++do_test "" $test
++
++# Restart GDB and 'source' the script; this will (still) run the program
++# due to the 'run' command in the script.
++clean_restart $binfile
++do_test "source $x_file" "load and run script using source command"
++
++# This should leave us at the gdb prompt; Run program again using
++# already established breakpoints, i.e. those loaded from the
++# script. Prior to fixing PR 28308, this was the only test that
++# would pass.
++do_test "run" "run again"
+diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb b/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.gdb
+@@ -0,0 +1,21 @@
++# Copyright 2021 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++dprintf increment, "dprintf in increment(), vi=%d\n", vi
++break inc_vi
++commands
++ continue
++end
++run
diff --git a/gdb-rhbz202487-rework-set-debuginfod.patch b/gdb-rhbz202487-rework-set-debuginfod.patch
new file mode 100644
index 0000000..a6b9bc4
--- /dev/null
+++ b/gdb-rhbz202487-rework-set-debuginfod.patch
@@ -0,0 +1,476 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Tue, 11 Jan 2022 12:46:05 +0100
+Subject: gdb-rhbz202487-rework-set-debuginfod.patch
+
+;;Backport upstream commit from Simon Marchi
+;;333f35b6315 gdb: pass/return setting setter/getter
+;;scalar values by value
+
+gdb: rework "set debuginfod" commands
+
+As discussed here [1], do some re-work in the "set debuginfod commands".
+
+First, use "set debuginfod enabled on/off/ask" instead of "set
+debuginfod on/off/ask". This is more MI-friendly, and it gives an
+output that makes more sense in "info set", for example.
+
+Then, make the show commands not call "error" when debuginfod support is
+not compiled in. This makes the commands "show" and "show debuginfod"
+stop early, breaking gdb.base/default.exp:
+
+ Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/default.exp ...
+ FAIL: gdb.base/default.exp: info set
+ FAIL: gdb.base/default.exp: show
+
+ - Make the "debuginfod enabled" setting default to "off" when debuginfod
+ support is not compiled in, and "ask" otherwise.
+ - Make the setter of "debuginfod enabled" error out when debuginfod
+ support is not compiled in, so that "debuginfod enabled" will always
+ remain "off" in that case.
+ - Make the setter of "debuginfod verbose" work in any case. I don't
+ see the harm in letting the user change that setting, since the user will
+ hit an error if they try to enable the use of debuginfod.
+ - I would do the same for the "debuginfod urls" setter, but because
+ this one needs to see the DEBUGINFOD_URLS_ENV_VAR macro, provided by
+ libdebuginfod, I made that one error out as well if debuginfod
+ support is not compiled it (otherwise, I would have left it like
+ "debuginfod verbose". Alternatively, we could hard-code
+ "DEBUGINFOD_URLS" in the code (in fact, it was prior to this patch,
+ but I think it was an oversight, as other spots use
+ DEBUGINFOD_URLS_ENV_VAR), or use a dummy string to store the setting,
+ but I don't really see the value in that.
+
+Rename debuginfod_enable to debuginfod_enabled, just so it matches the
+setting name.
+
+[1] https://sourceware.org/pipermail/gdb-patches/2021-October/182937.html
+
+Change-Id: I45fdb2993f668226a5639228951362b7800f09d5
+Co-Authored-By: Aaron Merey <amerey@redhat.com>
+
+diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
+--- a/gdb/debuginfod-support.c
++++ b/gdb/debuginfod-support.c
+@@ -32,8 +32,22 @@ static const char debuginfod_on[] = "on";
+ static const char debuginfod_off[] = "off";
+ static const char debuginfod_ask[] = "ask";
+
+-static const char *debuginfod_enable = debuginfod_ask;
+-static unsigned debuginfod_verbose = 1;
++static const char *debuginfod_enabled_enum[] =
++{
++ debuginfod_on,
++ debuginfod_off,
++ debuginfod_ask,
++ nullptr
++};
++
++static const char *debuginfod_enabled =
++#if defined(HAVE_LIBDEBUGINFOD)
++ debuginfod_ask;
++#else
++ debuginfod_off;
++#endif
++
++static unsigned int debuginfod_verbose = 1;
+
+ /* This is never actually used. URLs are always pulled from the
+ environment. */
+@@ -60,64 +74,6 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
+
+ #define NO_IMPL _("Support for debuginfod is not compiled into GDB.")
+
+-/* Stub set/show commands that indicate debuginfod is not supported. */
+-
+-static void
+-set_debuginfod_on_command (const char *args, int from_tty)
+-{
+- error (NO_IMPL);
+- debuginfod_enable = debuginfod_off;
+-}
+-
+-static void
+-set_debuginfod_off_command (const char *args, int from_tty)
+-{
+- error (NO_IMPL);
+- debuginfod_enable = debuginfod_off;
+-}
+-
+-static void
+-set_debuginfod_ask_command (const char *args, int from_tty)
+-{
+- error (NO_IMPL);
+- debuginfod_enable = debuginfod_off;
+-}
+-
+-static void
+-show_debuginfod_status_command (const char *args, int from_tty)
+-{
+- error (NO_IMPL);
+-}
+-
+-static void
+-set_debuginfod_urls_command (const char *ignore, int from_tty,
+- struct cmd_list_element *c)
+-{
+- error (NO_IMPL);
+-}
+-
+-static void
+-show_debuginfod_urls_command (struct ui_file *file, int from_tty,
+- struct cmd_list_element *cmd, const char *value)
+-{
+- error (NO_IMPL);
+-}
+-
+-static void
+-set_debuginfod_verbose_command (const char *args, int from_tty,
+- struct cmd_list_element *c)
+-{
+- error (NO_IMPL);
+- debuginfod_verbose = 0;
+-}
+-
+-static void
+-show_debuginfod_verbose_command (struct ui_file *file, int from_tty,
+- struct cmd_list_element *cmd,
+- const char *value)
+-{
+- error (NO_IMPL);
+-}
+ #else
+ #include <elfutils/debuginfod.h>
+
+@@ -145,82 +101,6 @@ struct debuginfod_client_deleter
+ using debuginfod_client_up
+ = std::unique_ptr<debuginfod_client, debuginfod_client_deleter>;
+
+-/* Enable debuginfod. */
+-
+-static void
+-set_debuginfod_on_command (const char *args, int from_tty)
+-{
+- debuginfod_enable = debuginfod_on;
+-}
+-
+-/* Disable debuginfod. */
+-
+-static void
+-set_debuginfod_off_command (const char *args, int from_tty)
+-{
+- debuginfod_enable = debuginfod_off;
+-}
+-
+-/* Before next query, ask user whether to enable debuginfod. */
+-
+-static void
+-set_debuginfod_ask_command (const char *args, int from_tty)
+-{
+- debuginfod_enable = debuginfod_ask;
+-}
+-
+-/* Show whether debuginfod is enabled. */
+-
+-static void
+-show_debuginfod_status_command (const char *args, int from_tty)
+-{
+- printf_unfiltered (_("Debuginfod functionality is currently set to " \
+- "\"%s\".\n"), debuginfod_enable);
+-}
+-
+-/* Set the URLs that debuginfod will query. */
+-
+-static void
+-set_debuginfod_urls_command (const char *ignore, int from_tty,
+- struct cmd_list_element *c)
+-{
+- gdb_assert (debuginfod_urls != nullptr);
+- if (setenv ("DEBUGINFOD_URLS", debuginfod_urls, 1) != 0)
+- warning (_("Unable to set debuginfod URLs: %s"), safe_strerror (errno));
+-}
+-
+-/* Show the URLs that debuginfod will query. */
+-
+-static void
+-show_debuginfod_urls_command (struct ui_file *file, int from_tty,
+- struct cmd_list_element *cmd, const char *value)
+-{
+- if (value == nullptr || value[0] == '\0')
+- fprintf_unfiltered (file, _("Debuginfod URLs have not been set.\n"));
+- else
+- fprintf_filtered (file, _("Debuginfod URLs are currently set to:\n%s\n"),
+- value);
+-}
+-
+-/* No-op setter used for compatibility when gdb is built without debuginfod. */
+-
+-static void
+-set_debuginfod_verbose_command (const char *args, int from_tty,
+- struct cmd_list_element *c)
+-{
+- return;
+-}
+-
+-/* Show verbosity. */
+-
+-static void
+-show_debuginfod_verbose_command (struct ui_file *file, int from_tty,
+- struct cmd_list_element *cmd, const char *value)
+-{
+- fprintf_filtered (file, _("Debuginfod verbose output is set to %s.\n"),
+- value);
+-}
+-
+ static int
+ progressfn (debuginfod_client *c, long cur, long total)
+ {
+@@ -277,15 +157,15 @@ get_debuginfod_client ()
+ whether to enable debuginfod. */
+
+ static bool
+-debuginfod_enabled ()
++debuginfod_is_enabled ()
+ {
+ const char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
+
+ if (urls == nullptr || urls[0] == '\0'
+- || debuginfod_enable == debuginfod_off)
++ || debuginfod_enabled == debuginfod_off)
+ return false;
+
+- if (debuginfod_enable == debuginfod_ask)
++ if (debuginfod_enabled == debuginfod_ask)
+ {
+ int resp = nquery (_("\nThis GDB supports auto-downloading debuginfo " \
+ "from the following URLs:\n%s\nEnable debuginfod " \
+@@ -294,16 +174,16 @@ debuginfod_enabled ()
+ if (!resp)
+ {
+ printf_filtered (_("Debuginfod has been disabled.\nTo make this " \
+- "setting permanent, add \'set debuginfod off\' " \
+- "to .gdbinit.\n"));
+- debuginfod_enable = debuginfod_off;
++ "setting permanent, add \'set debuginfod " \
++ "enabled off\' to .gdbinit.\n"));
++ debuginfod_enabled = debuginfod_off;
+ return false;
+ }
+
+ printf_filtered (_("Debuginfod has been enabled.\nTo make this " \
+- "setting permanent, add \'set debuginfod on\' " \
+- "to .gdbinit.\n"));
+- debuginfod_enable = debuginfod_on;
++ "setting permanent, add \'set debuginfod enabled " \
++ "on\' to .gdbinit.\n"));
++ debuginfod_enabled = debuginfod_on;
+ }
+
+ return true;
+@@ -317,7 +197,7 @@ debuginfod_source_query (const unsigned char *build_id,
+ const char *srcpath,
+ gdb::unique_xmalloc_ptr<char> *destname)
+ {
+- if (!debuginfod_enabled ())
++ if (!debuginfod_is_enabled ())
+ return scoped_fd (-ENOSYS);
+
+ debuginfod_client *c = get_debuginfod_client ();
+@@ -354,7 +234,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
+ const char *filename,
+ gdb::unique_xmalloc_ptr<char> *destname)
+ {
+- if (!debuginfod_enabled ())
++ if (!debuginfod_is_enabled ())
+ return scoped_fd (-ENOSYS);
+
+ debuginfod_client *c = get_debuginfod_client ();
+@@ -382,6 +262,67 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
+ }
+ #endif
+
++/* Set callback for "set debuginfod enabled". */
++
++static void
++set_debuginfod_enabled (const char *args, int from_tty,
++ struct cmd_list_element *c)
++{
++#if defined(HAVE_LIBDEBUGINFOD)
++ /* Value is already set. */
++#else
++ error (NO_IMPL);
++#endif
++}
++
++/* Show callback for "set debuginfod enabled". */
++
++static void
++show_debuginfod_enabled (ui_file *file, int from_tty, cmd_list_element *cmd,
++ const char *value)
++{
++ printf_unfiltered (_("Debuginfod functionality is currently set to "
++ "\"%s\".\n"), debuginfod_enabled);
++}
++
++/* Set callback for "set debuginfod urls". */
++
++static void
++set_debuginfod_urls (const char *args, int from_tty,
++ struct cmd_list_element *c)
++{
++#if defined(HAVE_LIBDEBUGINFOD)
++ gdb_assert (debuginfod_urls != nullptr);
++ if (setenv (DEBUGINFOD_URLS_ENV_VAR, debuginfod_urls, 1) != 0)
++ warning (_("Unable to set debuginfod URLs: %s"), safe_strerror (errno));
++#else
++ error (NO_IMPL);
++#endif
++}
++
++/* Show callback for "set debuginfod urls". */
++
++static void
++show_debuginfod_urls (ui_file *file, int from_tty, cmd_list_element *cmd,
++ const char *value)
++{
++ if (value[0] == '\0')
++ fprintf_unfiltered (file, _("Debuginfod URLs have not been set.\n"));
++ else
++ fprintf_filtered (file, _("Debuginfod URLs are currently set to:\n%s\n"),
++ value);
++}
++
++/* Show callback for "set debuginfod verbose". */
++
++static void
++show_debuginfod_verbose_command (ui_file *file, int from_tty,
++ cmd_list_element *cmd, const char *value)
++{
++ fprintf_filtered (file, _("Debuginfod verbose output is set to %s.\n"),
++ value);
++}
++
+ /* Register debuginfod commands. */
+
+ void _initialize_debuginfod ();
+@@ -397,23 +338,17 @@ _initialize_debuginfod ()
+ _("Show debuginfod option."),
+ &show_debuginfod_prefix_list, 0, &showlist);
+
+- /* set debuginfod on */
+- add_cmd ("on", class_run, set_debuginfod_on_command,
+- _("Enable debuginfod."), &set_debuginfod_prefix_list);
+-
+- /* set debuginfod off */
+- add_cmd ("off", class_run, set_debuginfod_off_command,
+- _("Disable debuginfod."), &set_debuginfod_prefix_list);
+-
+- /* set debuginfod ask */
+- add_cmd ("ask", class_run, set_debuginfod_ask_command, _("\
+-Ask the user whether to enable debuginfod before performing the next query."),
+- &set_debuginfod_prefix_list);
+-
+- /* show debuginfod status */
+- add_cmd ("status", class_run, show_debuginfod_status_command,
+- _("Show whether debuginfod is set to \"on\", \"off\" or \"ask\"."),
+- &show_debuginfod_prefix_list);
++ add_setshow_enum_cmd ("enabled", class_run, debuginfod_enabled_enum,
++ &debuginfod_enabled,
++ _("Set whether to use debuginfod."),
++ _("Show whether to use debuginfod."),
++ _("\
++When on, enable the use of debuginfod to download missing debug info and\n\
++source files."),
++ set_debuginfod_enabled,
++ show_debuginfod_enabled,
++ &set_debuginfod_prefix_list,
++ &show_debuginfod_prefix_list);
+
+ /* set/show debuginfod urls */
+ add_setshow_string_noescape_cmd ("urls", class_run, &debuginfod_urls, _("\
+@@ -422,8 +357,8 @@ Show the list of debuginfod server URLs."), _("\
+ Manage the space-separated list of debuginfod server URLs that GDB will query \
+ when missing debuginfo, executables or source files.\nThe default value is \
+ copied from the DEBUGINFOD_URLS environment variable."),
+- set_debuginfod_urls_command,
+- show_debuginfod_urls_command,
++ set_debuginfod_urls,
++ show_debuginfod_urls,
+ &set_debuginfod_prefix_list,
+ &show_debuginfod_prefix_list);
+ if (getenv ("DEBUGINFOD_URLS") != nullptr)
+@@ -436,7 +371,7 @@ Set verbosity of debuginfod output."), _("\
+ Show debuginfod debugging."), _("\
+ When set to a non-zero value, display verbose output for each debuginfod \
+ query.\nTo disable, set to zero. Verbose output is displayed by default."),
+- set_debuginfod_verbose_command,
++ nullptr,
+ show_debuginfod_verbose_command,
+ &set_debuginfod_prefix_list,
+ &show_debuginfod_prefix_list);
+diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
+--- a/gdb/doc/gdb.texinfo
++++ b/gdb/doc/gdb.texinfo
+@@ -47046,27 +47046,28 @@ regarding @code{debuginfod}.
+ @value{GDBN} provides the following commands for configuring @code{debuginfod}.
+
+ @table @code
+-@kindex set debuginfod
+-@anchor{set debuginfod}
+-@item set debuginfod
+-@itemx set debuginfod on
++@kindex set debuginfod enabled
++@anchor{set debuginfod enabled}
++@item set debuginfod enabled
++@itemx set debuginfod enabled on
+ @cindex enable debuginfod
+ @value{GDBN} will attempt to query @code{debuginfod} servers when missing debug
+ info or source files.
+
+-@item set debuginfod off
++@item set debuginfod enabled off
+ @value{GDBN} will not attempt to query @code{debuginfod} servers when missing
+-debug info or source files. By default, @code{debuginfod} is set to @code{off}
+-for non-interactive sessions.
++debug info or source files. By default, @code{debuginfod enabled} is set to
++@code{off} for non-interactive sessions.
+
+-@item set debuginfod ask
++@item set debuginfod enabled ask
+ @value{GDBN} will prompt the user to enable or disable @code{debuginfod} before
+-attempting to perform the next query. By default, @code{debuginfod} is set to
+-@code{ask} for interactive sessions.
++attempting to perform the next query. By default, @code{debuginfod enabled}
++is set to @code{ask} for interactive sessions.
+
+-@kindex show debuginfod status
+-@item show debuginfod status
+-Show whether @code{debuginfod} is set to @code{on}, @code{off} or @code{ask}.
++@kindex show debuginfod enabled
++@item show debuginfod enabled
++Display whether @code{debuginfod enabled} is set to @code{on}, @code{off} or
++@code{ask}.
+
+ @kindex set debuginfod urls
+ @cindex configure debuginfod URLs
+diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
++++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+@@ -236,7 +236,7 @@ proc local_url { } {
+ clean_restart
+ gdb_test "file $binfile" ".*No debugging symbols.*" \
+ "file [file tail $binfile] cmd"
+- gdb_test_no_output "set debuginfod off"
++ gdb_test_no_output "set debuginfod enabled off"
+ gdb_test_no_output "set debuginfod urls http://127.0.0.1:$port"
+
+ # gdb shouldn't find the debuginfo since debuginfod has been disabled
+@@ -244,7 +244,7 @@ proc local_url { } {
+ "file [file tail $binfile] cmd off"
+
+ # Enable debuginfod and fetch the debuginfo
+- gdb_test_no_output "set debuginfod on"
++ gdb_test_no_output "set debuginfod enabled on"
+ gdb_test "file $binfile" ".*Reading symbols from.*debuginfo.*" \
+ "file [file tail $binfile] cmd on"
+ }
diff --git a/gdb-rhbz2024875-expand-documentation-for-debuginfod.patch b/gdb-rhbz2024875-expand-documentation-for-debuginfod.patch
new file mode 100644
index 0000000..cdf3bf4
--- /dev/null
+++ b/gdb-rhbz2024875-expand-documentation-for-debuginfod.patch
@@ -0,0 +1,152 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Mon, 10 Jan 2022 13:00:50 +0100
+Subject: gdb-rhbz2024875-expand-documentation-for-debuginfod.patch
+
+;;Backport upstream commit from Aaron Merey
+;;3ea44f21299 gdb.texinfo: Expand documentation for debuginfod
+
+gdb.texinfo: Expand documentation for debuginfod
+
+Add section describing GDB's usage of debuginfod.
+
+Refer to this new section in the description of the '--with-debuginfod'
+configure option.
+
+Mention debuginfod in the 'Separate Debug Files' section.
+
+diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
+--- a/gdb/doc/gdb.texinfo
++++ b/gdb/doc/gdb.texinfo
+@@ -184,6 +184,7 @@ software in general. We will miss him.
+ the operating system
+ * Trace File Format:: GDB trace file format
+ * Index Section Format:: .gdb_index section format
++* Debuginfod:: Download debugging resources with @code{debuginfod}
+ * Man Pages:: Manual pages
+ * Copying:: GNU General Public License says
+ how you can copy and share GDB
+@@ -21373,7 +21374,9 @@ For the ``build ID'' method, @value{GDBN} looks in the
+ a file named @file{@var{nn}/@var{nnnnnnnn}.debug}, where @var{nn} are the
+ first 2 hex characters of the build ID bit string, and @var{nnnnnnnn}
+ are the rest of the bit string. (Real build ID strings are 32 or more
+-hex characters, not 10.)
++hex characters, not 10.) @value{GDBN} can automatically query
++@code{debuginfod} servers using build IDs in order to download separate debug
++files that cannot be found locally. For more information see @ref{Debuginfod}.
+ @end itemize
+
+ So, for example, suppose you ask @value{GDBN} to debug
+@@ -21394,6 +21397,10 @@ debug information files, in the indicated order:
+ @file{/usr/lib/debug/usr/bin/ls.debug}.
+ @end itemize
+
++If the debug file still has not been found and @code{debuginfod}
++(@pxref{Debuginfod}) is enabled, @value{GDBN} will attempt to download the
++file from @code{debuginfod} servers.
++
+ @anchor{debug-file-directory}
+ Global debugging info directories default to what is set by @value{GDBN}
+ configure option @option{--with-separate-debug-dir}. During @value{GDBN} run
+@@ -38746,12 +38753,12 @@ Use the curses library instead of the termcap library, for text-mode
+ terminal operations.
+
+ @item --with-debuginfod
+-Build @value{GDBN} with libdebuginfod, the debuginfod client library.
+-Used to automatically fetch source files and separate debug files from
+-debuginfod servers using the associated executable's build ID. Enabled
+-by default if libdebuginfod is installed and found at configure time.
+-debuginfod is packaged with elfutils, starting with version 0.178. You
+-can get the latest version from `https://sourceware.org/elfutils/'.
++Build @value{GDBN} with @file{libdebuginfod}, the @code{debuginfod} client
++library. Used to automatically fetch ELF, DWARF and source files from
++@code{debuginfod} servers using build IDs associated with any missing
++files. Enabled by default if @file{libdebuginfod} is installed and found
++at configure time. For more information regarding @code{debuginfod} see
++@ref{Debuginfod}.
+
+ @item --with-libunwind-ia64
+ Use the libunwind library for unwinding function call stack on ia64
+@@ -47012,6 +47019,82 @@ switch (die->tag)
+ @}
+ @end smallexample
+
++@node Debuginfod
++@appendix Download debugging resources with Debuginfod
++@cindex debuginfod
++
++@code{debuginfod} is an HTTP server for distributing ELF, DWARF and source
++files.
++
++With the @code{debuginfod} client library, @file{libdebuginfod}, @value{GDBN}
++can query servers using the build IDs associated with missing debug info,
++executables and source files in order to download them on demand.
++
++For instructions on building @value{GDBN} with @file{libdebuginfod},
++@pxref{Configure Options,,--with-debuginfod}. @code{debuginfod} is packaged
++with @code{elfutils}, starting with version 0.178. See
++@uref{https://sourceware.org/elfutils/Debuginfod.html} for more information
++regarding @code{debuginfod}.
++
++@menu
++* Debuginfod Settings:: Configuring debuginfod with @value{GDBN}
++@end menu
++
++@node Debuginfod Settings
++@section Debuginfod Settings
++
++@value{GDBN} provides the following commands for configuring @code{debuginfod}.
++
++@table @code
++@kindex set debuginfod
++@anchor{set debuginfod}
++@item set debuginfod
++@itemx set debuginfod on
++@cindex enable debuginfod
++@value{GDBN} will attempt to query @code{debuginfod} servers when missing debug
++info or source files.
++
++@item set debuginfod off
++@value{GDBN} will not attempt to query @code{debuginfod} servers when missing
++debug info or source files. By default, @code{debuginfod} is set to @code{off}
++for non-interactive sessions.
++
++@item set debuginfod ask
++@value{GDBN} will prompt the user to enable or disable @code{debuginfod} before
++attempting to perform the next query. By default, @code{debuginfod} is set to
++@code{ask} for interactive sessions.
++
++@kindex show debuginfod status
++@item show debuginfod status
++Show whether @code{debuginfod} is set to @code{on}, @code{off} or @code{ask}.
++
++@kindex set debuginfod urls
++@cindex configure debuginfod URLs
++@item set debuginfod urls
++@itemx set debuginfod urls @var{urls}
++Set the space-separated list of URLs that @code{debuginfod} will attempt to
++query. Only @code{http://}, @code{https://} and @code{file://} protocols
++should be used. The default value of @code{debuginfod urls} is copied from
++the @var{DEBUGINFOD_URLS} environment variable.
++
++@kindex show debuginfod urls
++@item show debuginfod urls
++Display the list of URLs that @code{debuginfod} will attempt to query.
++
++@kindex set debuginfod verbose
++@cindex debuginfod verbosity
++@item set debuginfod verbose
++@itemx set debuginfod verbose @var{n}
++Enable or disable @code{debuginfod}-related output. Use a non-zero value
++to enable and @code{0} to disable. @code{debuginfod} output is shown by
++default.
++
++@kindex show debuginfod verbose
++@item show debuginfod verbose
++Show the current verbosity setting.
++
++@end table
++
+ @node Man Pages
+ @appendix Manual pages
+ @cindex Man pages
diff --git a/gdb-rhbz2024875-fix-unittest-failure.patch b/gdb-rhbz2024875-fix-unittest-failure.patch
new file mode 100644
index 0000000..66f21d6
--- /dev/null
+++ b/gdb-rhbz2024875-fix-unittest-failure.patch
@@ -0,0 +1,37 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Tue, 11 Jan 2022 12:22:29 +0100
+Subject: gdb-rhbz2024875-fix-unittest-failure.patch
+
+;;Backport upstream commit from Tom Tromey
+;;2a8f1f47446 Fix unittest.exp failure due to 'set debuginfod' addition
+
+Fix unittest.exp failure due to 'set debuginfod' addition
+
+The 'set debuginfod' change caused a regression in unittest.exp:
+
+ Running selftest help_doc_invariants.
+ help doc broken invariant: command 'info set debuginfod' help doc first line is not terminated with a '.' character
+ help doc broken invariant: command 'set debuginfod' help doc first line is not terminated with a '.' character
+ help doc broken invariant: command 'show debuginfod' help doc first line is not terminated with a '.' character
+ Self test failed: self-test failed at ../../binutils-gdb/gdb/unittests/command-def-selftests.c:100
+
+This patch fixes the problem. I'm checking it in.
+
+diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
+--- a/gdb/debuginfod-support.c
++++ b/gdb/debuginfod-support.c
+@@ -390,11 +390,11 @@ _initialize_debuginfod ()
+ {
+ /* set/show debuginfod */
+ add_basic_prefix_cmd ("debuginfod", class_run,
+- _("Set debuginfod options"),
++ _("Set debuginfod options."),
+ &set_debuginfod_prefix_list, 0, &setlist);
+
+ add_show_prefix_cmd ("debuginfod", class_run,
+- _("Show debuginfod options"),
++ _("Show debuginfod option."),
+ &show_debuginfod_prefix_list, 0, &showlist);
+
+ /* set debuginfod on */
diff --git a/gdb-rhbz2024875-pr27026.patch b/gdb-rhbz2024875-pr27026.patch
new file mode 100644
index 0000000..f84f134
--- /dev/null
+++ b/gdb-rhbz2024875-pr27026.patch
@@ -0,0 +1,60 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Tue, 11 Jan 2022 13:22:44 +0100
+Subject: gdb-rhbz2024875-pr27026.patch
+
+;;Backport upstream commit from Aaron Merey
+;;b9db26b4c44 [PR gdb/27026] CTRL-C is ignored when debug info is downloaded
+
+[PR gdb/27026] CTRL-C is ignored when debug info is downloaded
+
+During debuginfod downloads, ctrl-c should result in the download
+being cancelled and skipped. However in some cases, ctrl-c fails to
+get delivered to gdb during downloading. This can result in downloads
+being unskippable.
+
+Fix this by ensuring that target_terminal::ours is in effect for the
+duration of each download.
+
+Co-authored-by: Tom de Vries <tdevries@suse.de>
+https://sourceware.org/bugzilla/show_bug.cgi?id=27026#c3
+
+diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
+--- a/gdb/debuginfod-support.c
++++ b/gdb/debuginfod-support.c
+@@ -23,6 +23,7 @@
+ #include "gdbsupport/gdb_optional.h"
+ #include "cli/cli-cmds.h"
+ #include "cli/cli-style.h"
++#include "target.h"
+
+ /* Set/show debuginfod commands. */
+ static cmd_list_element *set_debuginfod_prefix_list;
+@@ -208,6 +209,13 @@ debuginfod_source_query (const unsigned char *build_id,
+ user_data data ("source file", srcpath);
+
+ debuginfod_set_user_data (c, &data);
++ gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
++ if (target_supports_terminal_ours ())
++ {
++ term_state.emplace ();
++ target_terminal::ours ();
++ }
++
+ scoped_fd fd (debuginfod_find_source (c,
+ build_id,
+ build_id_len,
+@@ -246,6 +254,13 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
+ user_data data ("separate debug info for", filename);
+
+ debuginfod_set_user_data (c, &data);
++ gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
++ if (target_supports_terminal_ours ())
++ {
++ term_state.emplace ();
++ target_terminal::ours ();
++ }
++
+ scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len,
+ &dname));
+ debuginfod_set_user_data (c, nullptr);
diff --git a/gdb-rhbz2024875-set_show-for-managing-debuginfod.patch b/gdb-rhbz2024875-set_show-for-managing-debuginfod.patch
new file mode 100644
index 0000000..26ab2a4
--- /dev/null
+++ b/gdb-rhbz2024875-set_show-for-managing-debuginfod.patch
@@ -0,0 +1,414 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Mon, 10 Jan 2022 13:35:45 +0100
+Subject: gdb-rhbz2024875-set_show-for-managing-debuginfod.patch
+
+;;Backport upstream commit from Aaron Merey
+;;7811fa5995f gdb: add set/show commands for managing debuginfo
+
+gdb: add set/show commands for managing debuginfod
+
+Add 'set debuginfod' command. Accepts 'on', 'off' or 'ask' as an
+argument. 'on' enables debuginfod for the current session. 'off'
+disables debuginfod for the current session. 'ask' will prompt
+the user to either enable or disable debuginfod when the next query
+is about to be performed:
+
+ This GDB supports auto-downloading debuginfo from the following URLs:
+ <URL1> <URL2> ...
+ Enable debuginfod for this session? (y or [n]) y
+ Debuginfod has been enabled.
+ To make this setting permanent, add 'set debuginfod on' to .gdbinit.
+
+For interactive sessions, 'ask' is the default. For non-interactive
+sessions, 'off' is the default.
+
+Add 'show debuginfod status' command. Displays whether debuginfod
+is set to 'on', 'off' or 'ask'.
+
+Add 'set/show debuginfod urls' commands. Accepts a string of
+space-separated debuginfod server URLs to be queried. The default
+value is copied from the DEBUGINFOD_URLS environment variable.
+
+Finally add 'set/show debuginfod verbose' commands to control whether
+debuginfod-related output is displayed. Verbose output is enabled
+by default.
+
+ (gdb) run
+ Starting program: /bin/sleep 5
+ Download failed: No route to host. Continuing without debug info for /lib64/libc.so.6.
+
+If GDB is not built with debuginfod then these commands will just display
+
+ Support for debuginfod is not compiled into GDB.
+
+diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
+--- a/gdb/debuginfod-support.c
++++ b/gdb/debuginfod-support.c
+@@ -18,10 +18,26 @@
+
+ #include "defs.h"
+ #include <errno.h>
+-#include "cli/cli-style.h"
+ #include "gdbsupport/scoped_fd.h"
+ #include "debuginfod-support.h"
+ #include "gdbsupport/gdb_optional.h"
++#include "cli/cli-cmds.h"
++#include "cli/cli-style.h"
++
++/* Set/show debuginfod commands. */
++static cmd_list_element *set_debuginfod_prefix_list;
++static cmd_list_element *show_debuginfod_prefix_list;
++
++static const char debuginfod_on[] = "on";
++static const char debuginfod_off[] = "off";
++static const char debuginfod_ask[] = "ask";
++
++static const char *debuginfod_enable = debuginfod_ask;
++static unsigned debuginfod_verbose = 1;
++
++/* This is never actually used. URLs are always pulled from the
++ environment. */
++static char *debuginfod_urls;
+
+ #ifndef HAVE_LIBDEBUGINFOD
+ scoped_fd
+@@ -41,6 +57,67 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
+ {
+ return scoped_fd (-ENOSYS);
+ }
++
++#define NO_IMPL _("Support for debuginfod is not compiled into GDB.")
++
++/* Stub set/show commands that indicate debuginfod is not supported. */
++
++static void
++set_debuginfod_on_command (const char *args, int from_tty)
++{
++ error (NO_IMPL);
++ debuginfod_enable = debuginfod_off;
++}
++
++static void
++set_debuginfod_off_command (const char *args, int from_tty)
++{
++ error (NO_IMPL);
++ debuginfod_enable = debuginfod_off;
++}
++
++static void
++set_debuginfod_ask_command (const char *args, int from_tty)
++{
++ error (NO_IMPL);
++ debuginfod_enable = debuginfod_off;
++}
++
++static void
++show_debuginfod_status_command (const char *args, int from_tty)
++{
++ error (NO_IMPL);
++}
++
++static void
++set_debuginfod_urls_command (const char *ignore, int from_tty,
++ struct cmd_list_element *c)
++{
++ error (NO_IMPL);
++}
++
++static void
++show_debuginfod_urls_command (struct ui_file *file, int from_tty,
++ struct cmd_list_element *cmd, const char *value)
++{
++ error (NO_IMPL);
++}
++
++static void
++set_debuginfod_verbose_command (const char *args, int from_tty,
++ struct cmd_list_element *c)
++{
++ error (NO_IMPL);
++ debuginfod_verbose = 0;
++}
++
++static void
++show_debuginfod_verbose_command (struct ui_file *file, int from_tty,
++ struct cmd_list_element *cmd,
++ const char *value)
++{
++ error (NO_IMPL);
++}
+ #else
+ #include <elfutils/debuginfod.h>
+
+@@ -68,6 +145,82 @@ struct debuginfod_client_deleter
+ using debuginfod_client_up
+ = std::unique_ptr<debuginfod_client, debuginfod_client_deleter>;
+
++/* Enable debuginfod. */
++
++static void
++set_debuginfod_on_command (const char *args, int from_tty)
++{
++ debuginfod_enable = debuginfod_on;
++}
++
++/* Disable debuginfod. */
++
++static void
++set_debuginfod_off_command (const char *args, int from_tty)
++{
++ debuginfod_enable = debuginfod_off;
++}
++
++/* Before next query, ask user whether to enable debuginfod. */
++
++static void
++set_debuginfod_ask_command (const char *args, int from_tty)
++{
++ debuginfod_enable = debuginfod_ask;
++}
++
++/* Show whether debuginfod is enabled. */
++
++static void
++show_debuginfod_status_command (const char *args, int from_tty)
++{
++ printf_unfiltered (_("Debuginfod functionality is currently set to " \
++ "\"%s\".\n"), debuginfod_enable);
++}
++
++/* Set the URLs that debuginfod will query. */
++
++static void
++set_debuginfod_urls_command (const char *ignore, int from_tty,
++ struct cmd_list_element *c)
++{
++ gdb_assert (debuginfod_urls != nullptr);
++ if (setenv ("DEBUGINFOD_URLS", debuginfod_urls, 1) != 0)
++ warning (_("Unable to set debuginfod URLs: %s"), safe_strerror (errno));
++}
++
++/* Show the URLs that debuginfod will query. */
++
++static void
++show_debuginfod_urls_command (struct ui_file *file, int from_tty,
++ struct cmd_list_element *cmd, const char *value)
++{
++ if (value == nullptr || value[0] == '\0')
++ fprintf_unfiltered (file, _("Debuginfod URLs have not been set.\n"));
++ else
++ fprintf_filtered (file, _("Debuginfod URLs are currently set to:\n%s\n"),
++ value);
++}
++
++/* No-op setter used for compatibility when gdb is built without debuginfod. */
++
++static void
++set_debuginfod_verbose_command (const char *args, int from_tty,
++ struct cmd_list_element *c)
++{
++ return;
++}
++
++/* Show verbosity. */
++
++static void
++show_debuginfod_verbose_command (struct ui_file *file, int from_tty,
++ struct cmd_list_element *cmd, const char *value)
++{
++ fprintf_filtered (file, _("Debuginfod verbose output is set to %s.\n"),
++ value);
++}
++
+ static int
+ progressfn (debuginfod_client *c, long cur, long total)
+ {
+@@ -120,6 +273,42 @@ get_debuginfod_client ()
+ return global_client.get ();
+ }
+
++/* Check if debuginfod is enabled. If configured to do so, ask the user
++ whether to enable debuginfod. */
++
++static bool
++debuginfod_enabled ()
++{
++ const char *urls = getenv (DEBUGINFOD_URLS_ENV_VAR);
++
++ if (urls == nullptr || urls[0] == '\0'
++ || debuginfod_enable == debuginfod_off)
++ return false;
++
++ if (debuginfod_enable == debuginfod_ask)
++ {
++ int resp = nquery (_("\nThis GDB supports auto-downloading debuginfo " \
++ "from the following URLs:\n%s\nEnable debuginfod " \
++ "for this session? "),
++ urls);
++ if (!resp)
++ {
++ printf_filtered (_("Debuginfod has been disabled.\nTo make this " \
++ "setting permanent, add \'set debuginfod off\' " \
++ "to .gdbinit.\n"));
++ debuginfod_enable = debuginfod_off;
++ return false;
++ }
++
++ printf_filtered (_("Debuginfod has been enabled.\nTo make this " \
++ "setting permanent, add \'set debuginfod on\' " \
++ "to .gdbinit.\n"));
++ debuginfod_enable = debuginfod_on;
++ }
++
++ return true;
++}
++
+ /* See debuginfod-support.h */
+
+ scoped_fd
+@@ -128,8 +317,7 @@ debuginfod_source_query (const unsigned char *build_id,
+ const char *srcpath,
+ gdb::unique_xmalloc_ptr<char> *destname)
+ {
+- const char *urls_env_var = getenv (DEBUGINFOD_URLS_ENV_VAR);
+- if (urls_env_var == NULL || urls_env_var[0] == '\0')
++ if (!debuginfod_enabled ())
+ return scoped_fd (-ENOSYS);
+
+ debuginfod_client *c = get_debuginfod_client ();
+@@ -147,8 +335,7 @@ debuginfod_source_query (const unsigned char *build_id,
+ nullptr));
+ debuginfod_set_user_data (c, nullptr);
+
+- /* TODO: Add 'set debug debuginfod' command to control when error messages are shown. */
+- if (fd.get () < 0 && fd.get () != -ENOENT)
++ if (debuginfod_verbose > 0 && fd.get () < 0 && fd.get () != -ENOENT)
+ printf_filtered (_("Download failed: %s. Continuing without source file %ps.\n"),
+ safe_strerror (-fd.get ()),
+ styled_string (file_name_style.style (), srcpath));
+@@ -167,8 +354,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
+ const char *filename,
+ gdb::unique_xmalloc_ptr<char> *destname)
+ {
+- const char *urls_env_var = getenv (DEBUGINFOD_URLS_ENV_VAR);
+- if (urls_env_var == NULL || urls_env_var[0] == '\0')
++ if (!debuginfod_enabled ())
+ return scoped_fd (-ENOSYS);
+
+ debuginfod_client *c = get_debuginfod_client ();
+@@ -184,7 +370,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
+ &dname));
+ debuginfod_set_user_data (c, nullptr);
+
+- if (fd.get () < 0 && fd.get () != -ENOENT)
++ if (debuginfod_verbose > 0 && fd.get () < 0 && fd.get () != -ENOENT)
+ printf_filtered (_("Download failed: %s. Continuing without debug info for %ps.\n"),
+ safe_strerror (-fd.get ()),
+ styled_string (file_name_style.style (), filename));
+@@ -195,3 +381,63 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
+ return fd;
+ }
+ #endif
++
++/* Register debuginfod commands. */
++
++void _initialize_debuginfod ();
++void
++_initialize_debuginfod ()
++{
++ /* set/show debuginfod */
++ add_basic_prefix_cmd ("debuginfod", class_run,
++ _("Set debuginfod options"),
++ &set_debuginfod_prefix_list, 0, &setlist);
++
++ add_show_prefix_cmd ("debuginfod", class_run,
++ _("Show debuginfod options"),
++ &show_debuginfod_prefix_list, 0, &showlist);
++
++ /* set debuginfod on */
++ add_cmd ("on", class_run, set_debuginfod_on_command,
++ _("Enable debuginfod."), &set_debuginfod_prefix_list);
++
++ /* set debuginfod off */
++ add_cmd ("off", class_run, set_debuginfod_off_command,
++ _("Disable debuginfod."), &set_debuginfod_prefix_list);
++
++ /* set debuginfod ask */
++ add_cmd ("ask", class_run, set_debuginfod_ask_command, _("\
++Ask the user whether to enable debuginfod before performing the next query."),
++ &set_debuginfod_prefix_list);
++
++ /* show debuginfod status */
++ add_cmd ("status", class_run, show_debuginfod_status_command,
++ _("Show whether debuginfod is set to \"on\", \"off\" or \"ask\"."),
++ &show_debuginfod_prefix_list);
++
++ /* set/show debuginfod urls */
++ add_setshow_string_noescape_cmd ("urls", class_run, &debuginfod_urls, _("\
++Set the list of debuginfod server URLs."), _("\
++Show the list of debuginfod server URLs."), _("\
++Manage the space-separated list of debuginfod server URLs that GDB will query \
++when missing debuginfo, executables or source files.\nThe default value is \
++copied from the DEBUGINFOD_URLS environment variable."),
++ set_debuginfod_urls_command,
++ show_debuginfod_urls_command,
++ &set_debuginfod_prefix_list,
++ &show_debuginfod_prefix_list);
++ if (getenv ("DEBUGINFOD_URLS") != nullptr)
++ debuginfod_urls = xstrdup (getenv ("DEBUGINFOD_URLS"));
++
++ /* set/show debuginfod verbose */
++ add_setshow_zuinteger_cmd ("verbose", class_support,
++ &debuginfod_verbose, _("\
++Set verbosity of debuginfod output."), _("\
++Show debuginfod debugging."), _("\
++When set to a non-zero value, display verbose output for each debuginfod \
++query.\nTo disable, set to zero. Verbose output is displayed by default."),
++ set_debuginfod_verbose_command,
++ show_debuginfod_verbose_command,
++ &set_debuginfod_prefix_list,
++ &show_debuginfod_prefix_list);
++}
+diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
++++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+@@ -217,7 +217,8 @@ proc local_url { } {
+ setenv DEBUGINFOD_URLS http://127.0.0.1:$port
+
+ # gdb should now find the symbol and source files
+- clean_restart $binfile
++ clean_restart
++ gdb_test "file $binfile" "" "file [file tail $binfile]" "Enable debuginfod?.*" "y"
+ gdb_test_no_output "set substitute-path $outputdir /dev/null" \
+ "set substitute-path"
+ gdb_test "br main" "Breakpoint 1 at.*file.*"
+@@ -226,8 +227,26 @@ proc local_url { } {
+ # gdb should now find the debugaltlink file
+ clean_restart
+ gdb_test "file ${binfile}_alt.o" \
+- ".*Reading symbols from ${binfile}_alt.o\.\.\.*" \
+- "file [file tail ${binfile}_alt.o]"
++ ".*Downloading.*separate debug info.*" \
++ "file [file tail ${binfile}_alt.o]" \
++ ".*Enable debuginfod?.*" "y"
++
++ # Configure debuginfod with commands
++ unsetenv DEBUGINFOD_URLS
++ clean_restart
++ gdb_test "file $binfile" ".*No debugging symbols.*" \
++ "file [file tail $binfile] cmd"
++ gdb_test_no_output "set debuginfod off"
++ gdb_test_no_output "set debuginfod urls http://127.0.0.1:$port"
++
++ # gdb shouldn't find the debuginfo since debuginfod has been disabled
++ gdb_test "file $binfile" ".*No debugging symbols.*" \
++ "file [file tail $binfile] cmd off"
++
++ # Enable debuginfod and fetch the debuginfo
++ gdb_test_no_output "set debuginfod on"
++ gdb_test "file $binfile" ".*Reading symbols from.*debuginfo.*" \
++ "file [file tail $binfile] cmd on"
+ }
+
+ set envlist \
diff --git a/gdb-test-for-rhbz1976887.patch b/gdb-test-for-rhbz1976887.patch
new file mode 100644
index 0000000..3cb7049
--- /dev/null
+++ b/gdb-test-for-rhbz1976887.patch
@@ -0,0 +1,592 @@
+From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
+Date: Wed, 29 Sep 2021 11:14:51 +0200
+Subject: gdb-test-for-rhbz1976887.patch
+
+;; Backport test for RHBZ 1976887 (Kevin Buettner).
+
+Test case reproducing PR28030 bug
+
+The original reproducer for PR28030 required use of a specific
+compiler version - gcc-c++-11.1.1-3.fc34 is mentioned in the PR,
+though it seems probable that other gcc versions might also be able to
+reproduce the bug as well. This commit introduces a test case which,
+using the DWARF assembler, provides a reproducer which is independent
+of the compiler version. (Well, it'll work with whatever compilers
+the DWARF assembler works with.)
+
+To the best of my knowledge, it's also the first test case which uses
+the DWARF assembler to provide debug info for a shared object. That
+being the case, I provided more than the usual commentary which should
+allow this case to be used as a template when a combo shared
+library / DWARF assembler test case is required in the future.
+
+I provide some details regarding the bug in a comment near the
+beginning of locexpr-dml.exp.
+
+This problem was difficult to reproduce; I found myself constantly
+referring to the backtrace while trying to figure out what (else) I
+might be missing while trying to create a reproducer. Below is a
+partial backtrace which I include for posterity.
+
+ #0 internal_error (
+ file=0xc50110 "/ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c", line=5575,
+ fmt=0xc520c0 "Unexpected type field location kind: %d")
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdbsupport/errors.cc:51
+ #1 0x00000000006ef0c5 in copy_type_recursive (objfile=0x1635930,
+ type=0x274c260, copied_types=0x30bb290)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c:5575
+ #2 0x00000000006ef382 in copy_type_recursive (objfile=0x1635930,
+ type=0x274ca10, copied_types=0x30bb290)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c:5602
+ #3 0x0000000000a7409a in preserve_one_value (value=0x24269f0,
+ objfile=0x1635930, copied_types=0x30bb290)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/value.c:2529
+ #4 0x000000000072012a in gdbscm_preserve_values (
+ extlang=0xc55720 <extension_language_guile>, objfile=0x1635930,
+ copied_types=0x30bb290)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/guile/scm-value.c:94
+ #5 0x00000000006a3f82 in preserve_ext_lang_values (objfile=0x1635930,
+ copied_types=0x30bb290)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/extension.c:568
+ #6 0x0000000000a7428d in preserve_values (objfile=0x1635930)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/value.c:2579
+ #7 0x000000000082d514 in objfile::~objfile (this=0x1635930,
+ __in_chrg=<optimized out>)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:549
+ #8 0x0000000000831cc8 in std::_Sp_counted_ptr<objfile*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x1654580)
+ at /usr/include/c++/11/bits/shared_ptr_base.h:348
+ #9 0x00000000004e6617 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x1654580) at /usr/include/c++/11/bits/shared_ptr_base.h:168
+ #10 0x00000000004e1d2f in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x190bb88, __in_chrg=<optimized out>)
+ at /usr/include/c++/11/bits/shared_ptr_base.h:705
+ #11 0x000000000082feee in std::__shared_ptr<objfile, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x190bb80, __in_chrg=<optimized out>)
+ at /usr/include/c++/11/bits/shared_ptr_base.h:1154
+ #12 0x000000000082ff0a in std::shared_ptr<objfile>::~shared_ptr (
+ this=0x190bb80, __in_chrg=<optimized out>)
+ at /usr/include/c++/11/bits/shared_ptr.h:122
+ #13 0x000000000085ed7e in __gnu_cxx::new_allocator<std::_List_node<std::shared_ptr<objfile> > >::destroy<std::shared_ptr<objfile> > (this=0x114bc00,
+ __p=0x190bb80) at /usr/include/c++/11/ext/new_allocator.h:168
+ #14 0x000000000085e88d in std::allocator_traits<std::allocator<std::_List_node<std::shared_ptr<objfile> > > >::destroy<std::shared_ptr<objfile> > (__a=...,
+ __p=0x190bb80) at /usr/include/c++/11/bits/alloc_traits.h:531
+ #15 0x000000000085e50c in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::_M_erase (this=0x114bc00, __position=
+ std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x1635930})
+ at /usr/include/c++/11/bits/stl_list.h:1925
+ #16 0x000000000085df0e in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::erase (this=0x114bc00, __position=
+ std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x1635930})
+ at /usr/include/c++/11/bits/list.tcc:158
+ #17 0x000000000085c748 in program_space::remove_objfile (this=0x114bbc0,
+ objfile=0x1635930)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/progspace.c:210
+ #18 0x000000000082d3ae in objfile::unlink (this=0x1635930)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:487
+ #19 0x000000000082e68c in objfile_purge_solibs ()
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:875
+ #20 0x000000000092dd37 in no_shared_libraries (ignored=0x0, from_tty=1)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/solib.c:1236
+ #21 0x00000000009a37fe in target_pre_inferior (from_tty=1)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/target.c:2496
+ #22 0x00000000007454d6 in run_command_1 (args=0x0, from_tty=1,
+ run_how=RUN_NORMAL)
+ at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/infcmd.c:437
+
+I'll note a few points regarding this backtrace:
+
+Frame #1 is where the internal error occurs. It's caused by an
+unhandled case for FIELD_LOC_KIND_DWARF_BLOCK. The fix for this bug
+adds support for this case.
+
+Frame #22 - it's a partial backtrace - shows that GDB is attempting to
+(re)run the program. You can see the exact command sequence that was
+used for reproducing this problem in the PR (at
+https://sourceware.org/bugzilla/show_bug.cgi?id=28030), but in a
+nutshell, after starting the program and advancing to the appropriate
+source line, GDB was asked to step into libstdc++; a "finish" command
+was issued, returning a value. The fact that a value was returned is
+very important. GDB was then used to step back into libstdc++. A
+breakpoint was set on a source line in the library after which a "run"
+command was issued.
+
+Frame #19 shows a call to objfile_purge_solibs. It's aptly named.
+
+Frame #7 is a call to the destructor for one of the objfile solibs; it
+turned out to be the one for libstdc++.
+
+Frames #6 thru #3 show various value preservation frames. If you look
+at preserve_values() in gdb/value.c, the value history is preserved
+first, followed by internal variables, followed by values for the
+extension languages (python and guile).
+
+diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c
+@@ -0,0 +1,48 @@
++/* Copyright (C) 2021 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include "locexpr-data-member-location.h"
++
++struct A g_A = {3, 4};
++struct B g_B = { {8, 9}, 10, 11 };
++
++B *
++foo ()
++{ /* foo prologue */
++ asm ("foo_label: .globl foo_label");
++ return &g_B; /* foo return */
++} /* foo end */
++
++B *
++bar (B *v)
++{ /* bar prologue */
++ asm ("bar_label: .globl bar_label");
++ return v; /* bar return */
++} /* bar end */
++
++/* Some of the DWARF assembler procs (e.g. function_range) compile
++ this file, expecting it to be a complete program with a main()
++ function. When IS_SHAREDLIB is NOT defined, we have main() as
++ defined below. */
++
++#ifndef IS_SHAREDLIB
++int
++main ()
++{
++ B *b = foo ();
++}
++#endif
+diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c
+@@ -0,0 +1,27 @@
++/* Copyright (C) 2021 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++#include "locexpr-data-member-location.h"
++
++int
++main (void)
++{
++ B *v1;
++ v1 = bar (foo ());
++
++ return 0;
++}
+diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
+@@ -0,0 +1,349 @@
++# Copyright 2021 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++# This test case uses the DWARF assembler to reproduce the problem
++# described by PR28030. The bug turned out to be that
++# FIELD_LOC_KIND_DWARF_BLOCK was not handled when recursively copying
++# a value's type when preserving the value history during the freeing
++# up of objfiles associated with a shared object. (Yes, figuring out
++# how to make this happen in a concise test case turned out to be
++# challenging.)
++#
++# The following elements proved to be necessary for reproducing the
++# problem:
++#
++# 1) A location expression needed to be used with
++# DW_AT_data_member_location rather than a simple offset.
++# Moreover, this location expression needed to use opcodes
++# which GDB's DWARF reader could not convert to a simple
++# offset. (Note, however, that GDB could probably be improved
++# to handle the opcodes chosen for this test; if decode_locdesc()
++# in dwarf2/read.c is ever updated to handle both DW_OP_pick and
++# DW_OP_drop, then this test could end up passing even if
++# the bug it's intended to test has not been fixed.)
++#
++# 2) The debug info containing the above DWARF info needed
++# to be associated with a shared object since the problem
++# occurred while GDB was preserving values during the
++# purging of shared objects.
++#
++# 3) After performing some simple gdb commands, the program is
++# run again. In the course of running the objfile destructor
++# associated with the shared object, values are preserved
++# along with their types. As noted earlier, it was during
++# the recursive type copy that the bug was observed.
++#
++# Therefore, due to #2 above, this test case creates debug info
++# which is then used by a shared object.
++
++# This test can't be run on targets lacking shared library support.
++if [skip_shlib_tests] {
++ return 0
++}
++
++load_lib dwarf.exp
++
++# This test can only be run on targets which support DWARF-2 and use gas.
++if ![dwarf2_support] {
++ return 0
++}
++
++# gdb_test_file_name is the name of this file without the .exp
++# extension. Use it to form basenames for the main program
++# and shared object.
++set main_basename ${::gdb_test_file_name}-main
++set lib_basename ${::gdb_test_file_name}-lib
++
++# We're generating DWARF assembly for the shared object; therefore,
++# the source file for the library / shared object must be listed first
++# (in the standard_testfile invocation) since ${srcfile} is used by
++# get_func_info (for determining the start, end, and length of a
++# function).
++#
++# The output of Dwarf::assemble will be placed in $lib_basename.S
++# which will be ${srcfile3} after the execution of standard_testfile.
++
++standard_testfile $lib_basename.c $main_basename.c $lib_basename.S
++
++set libsrc "${::srcdir}/${::subdir}/${::srcfile}"
++set lib_so [standard_output_file ${lib_basename}.so]
++set asm_file [standard_output_file ${::srcfile3}]
++
++# We need to know the size of some types in order to write some of the
++# debugging info that we're about to generate. For that, we ask GDB
++# by debugging the shared object associated with this test case.
++
++# Compile the shared library: -DIS_SHAREDLIB prevents main() from
++# being defined. Note that debugging symbols will be present for
++# this compilation.
++if {[gdb_compile_shlib $libsrc $lib_so \
++ {additional_flags=-DIS_SHAREDLIB debug}] != ""} {
++ untested "failed to compile shared library"
++ return
++}
++
++# Start a fresh GDB and load the shared library.
++clean_restart $lib_so
++
++# Using our running GDB session, determine sizes of several types.
++set long_size [get_sizeof "long" -1]
++set addr_size [get_sizeof "void *" -1]
++set struct_A_size [get_sizeof "g_A" -1]
++set struct_B_size [get_sizeof "g_B" -1]
++
++if { $long_size == -1 || $addr_size == -1 \
++ || $struct_A_size == -1 || $struct_B_size == -1} {
++ perror "Can't determine type sizes"
++ return
++}
++
++# Retrieve struct offset of MBR in struct TP
++proc get_offsetof { tp mbr } {
++ return [get_integer_valueof "&((${tp} *) 0)->${mbr}" -1]
++}
++
++# Use running GDB session to get struct offsets
++set A_a [get_offsetof A a]
++set A_x [get_offsetof A x]
++set B_a [get_offsetof B a]
++set B_b [get_offsetof B b]
++set B_x2 [get_offsetof B x2]
++
++# Create the DWARF.
++Dwarf::assemble ${asm_file} {
++ declare_labels L
++
++ # Find start, end, and length of functions foo and bar.
++ # These calls to get_func_info will create and set variables
++ # foo_start, bar_start, foo_end, bar_end, foo_len, and
++ # bar_len.
++ #
++ # In order to get the right answers, get_func_info (and,
++ # underneath, function_range) should use the same compiler flags
++ # as those used to make a shared object. For any targets that get
++ # this far, -fpic is probably correct.
++ #
++ # Also, it should be noted that IS_SHAREDLIB is NOT defined as one
++ # of the additional flags. Not defining IS_SHAREDLIB will cause a
++ # main() to be defined for the compilation of the shared library
++ # source file which happens as a result of using get_func_info;
++ # this is currently required in order to this facility.
++ set flags {additional_flags=-fpic debug}
++ get_func_info foo $flags
++ get_func_info bar $flags
++
++ cu {} {
++ DW_TAG_compile_unit {
++ {DW_AT_language @DW_LANG_C_plus_plus}
++ {name ${::srcfile}}
++ {stmt_list $L DW_FORM_sec_offset}
++ } {
++ declare_labels int_label class_A_label class_B_label \
++ B_ptr_label
++
++ int_label: DW_TAG_base_type {
++ {DW_AT_byte_size ${::long_size} DW_FORM_udata}
++ {DW_AT_encoding @DW_ATE_signed}
++ {DW_AT_name "int"}
++ }
++
++ class_A_label: DW_TAG_class_type {
++ {DW_AT_name "A"}
++ {DW_AT_byte_size ${::struct_A_size} DW_FORM_sdata}
++ } {
++ DW_TAG_member {
++ {DW_AT_name "a"}
++ {DW_AT_type :$int_label}
++ {DW_AT_data_member_location ${::A_a} DW_FORM_udata}
++ }
++ DW_TAG_member {
++ {DW_AT_name "x"}
++ {DW_AT_type :$int_label}
++ {DW_AT_data_member_location ${::A_x} DW_FORM_udata}
++ }
++ }
++
++ class_B_label: DW_TAG_class_type {
++ {DW_AT_name "B"}
++ {DW_AT_byte_size ${::struct_B_size} DW_FORM_sdata}
++ } {
++ # While there are easier / better ways to specify an
++ # offset used by DW_AT_data_member_location than that
++ # used below, we need a location expression here in
++ # order to reproduce the bug. Moreover, this location
++ # expression needs to use opcodes that aren't handled
++ # by decode_locdesc() in dwarf2/read.c; if we use
++ # opcodes that _are_ handled by that function, the
++ # location expression will be converted into a simple
++ # offset - which will then (again) not reproduce the
++ # bug. At the time that this test was written,
++ # neither DW_OP_pick nor DW_OP_drop were being handled
++ # by decode_locdesc(); this is why those opcodes were
++ # chosen.
++ DW_TAG_inheritance {
++ {DW_AT_type :$class_A_label}
++ {DW_AT_data_member_location {
++ DW_OP_constu ${::B_a}
++ DW_OP_plus
++ DW_OP_pick 0
++ DW_OP_drop} SPECIAL_expr}
++ {DW_AT_accessibility 1 DW_FORM_data1}
++ }
++ DW_TAG_member {
++ {DW_AT_name "b"}
++ {DW_AT_type :$int_label}
++ {DW_AT_data_member_location ${::B_b} DW_FORM_udata}
++ }
++ DW_TAG_member {
++ {DW_AT_name "x2"}
++ {DW_AT_type :$int_label}
++ {DW_AT_data_member_location ${::B_x2} DW_FORM_udata}
++ }
++ }
++
++ B_ptr_label: DW_TAG_pointer_type {
++ {DW_AT_type :$class_B_label}
++ {DW_AT_byte_size ${::addr_size} DW_FORM_sdata}
++ }
++
++ DW_TAG_variable {
++ {DW_AT_name "g_A"}
++ {DW_AT_type :$class_A_label}
++ {DW_AT_external 1 flag}
++ {DW_AT_location {DW_OP_addr [gdb_target_symbol "g_A"]} \
++ SPECIAL_expr}
++ }
++
++ DW_TAG_variable {
++ {DW_AT_name "g_B"}
++ {DW_AT_type :$class_B_label}
++ {DW_AT_external 1 flag}
++ {DW_AT_location {DW_OP_addr [gdb_target_symbol "g_B"]} \
++ SPECIAL_expr}
++ }
++
++ # We can't use MACRO_AT for the definitions of foo and bar
++ # because it doesn't provide a way to pass the appropriate
++ # flags. Therefore, we list the name, low_pc, and high_pc
++ # explicitly.
++ DW_TAG_subprogram {
++ {DW_AT_name foo}
++ {DW_AT_low_pc $foo_start DW_FORM_addr}
++ {DW_AT_high_pc $foo_end DW_FORM_addr}
++ {DW_AT_type :${B_ptr_label}}
++ {DW_AT_external 1 flag}
++ }
++
++ DW_TAG_subprogram {
++ {DW_AT_name bar}
++ {DW_AT_low_pc $bar_start DW_FORM_addr}
++ {DW_AT_high_pc $bar_end DW_FORM_addr}
++ {DW_AT_type :${B_ptr_label}}
++ {DW_AT_external 1 flag}
++ } {
++ DW_TAG_formal_parameter {
++ {DW_AT_name v}
++ {DW_AT_type :${B_ptr_label}}
++ }
++ }
++ }
++ }
++
++ lines {version 2} L {
++ include_dir "${::srcdir}/${::subdir}"
++ file_name "${::srcfile}" 1
++
++ # Generate a line table program.
++ program {
++ {DW_LNE_set_address $foo_start}
++ {line [gdb_get_line_number "foo prologue"]}
++ {DW_LNS_copy}
++ {DW_LNE_set_address foo_label}
++ {line [gdb_get_line_number "foo return"]}
++ {DW_LNS_copy}
++ {line [gdb_get_line_number "foo end"]}
++ {DW_LNS_copy}
++ {DW_LNE_set_address $foo_end}
++ {DW_LNS_advance_line 1}
++ {DW_LNS_copy}
++ {DW_LNE_end_sequence}
++
++ {DW_LNE_set_address $bar_start}
++ {line [gdb_get_line_number "bar prologue"]}
++ {DW_LNS_copy}
++ {DW_LNE_set_address bar_label}
++ {line [gdb_get_line_number "bar return"]}
++ {DW_LNS_copy}
++ {line [gdb_get_line_number "bar end"]}
++ {DW_LNS_copy}
++ {DW_LNE_set_address $bar_end}
++ {DW_LNS_advance_line 1}
++ {DW_LNS_copy}
++ {DW_LNE_end_sequence}
++ }
++ }
++}
++
++# Compile the shared object again, but this time include / use the
++# DWARF info that we've created above. Note that (again)
++# -DIS_SHAREDLIB is used to prevent inclusion of main() in the shared
++# object. Also note the use of the "nodebug" option. Any debugging
++# information that we need will be provided by the DWARF info created
++# above.
++if {[gdb_compile_shlib [list $libsrc $asm_file] $lib_so \
++ {additional_flags=-DIS_SHAREDLIB nodebug}] != ""} {
++ untested "failed to compile shared library"
++ return
++}
++
++# Compile the main program for use with the shared object.
++if [prepare_for_testing "failed to prepare" ${testfile} \
++ ${::srcfile2} [list debug shlib=$lib_so]] {
++ return -1
++}
++
++# Do whatever is necessary to make sure that the shared library is
++# loaded for remote targets.
++gdb_load_shlib ${lib_so}
++
++if ![runto_main] then {
++ fail "can't run to main"
++ return
++}
++
++# Step into foo so that we can finish out of it.
++gdb_test "step" "foo .. at .* foo end.*" "step into foo"
++
++# Finishing out of foo will create a value that will later need to
++# be preserved when restarting the program.
++gdb_test "finish" "= \\(class B \\*\\) ${::hex} .*" "finish out of foo"
++
++# Dereferencing and printing the return value isn't necessary
++# for reproducing the bug, but we should make sure that the
++# return value is what we expect it to be.
++gdb_test "p *$" { = {<A> = {a = 8, x = 9}, b = 10, x2 = 11}} \
++ "dereference return value"
++
++# The original PR28030 reproducer stepped back into the shared object,
++# so we'll do the same here:
++gdb_test "step" "bar \\(.*" "step into bar"
++
++# We don't want a clean restart here since that will be too clean.
++# The original reproducer for PR28030 set a breakpoint in the shared
++# library and then restarted via "run". The command below does roughly
++# the same thing. It's at this step that an internal error would
++# occur for PR28030. The "message" argument tells runto to turn on
++# the printing of PASSes while runto is doing its job.
++runto "bar" message
+diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h
+new file mode 100644
+--- /dev/null
++++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h
+@@ -0,0 +1,30 @@
++/* Copyright (C) 2021 Free Software Foundation, Inc.
++
++ This file is part of GDB.
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 3 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program. If not, see <http://www.gnu.org/licenses/>. */
++
++typedef struct A {
++ long a;
++ long x;
++} A;
++
++typedef struct B {
++ A a;
++ long b;
++ long x2;
++} B;
++
++extern B *foo ();
++extern B *bar (B *v);
diff --git a/gdb.spec b/gdb.spec
index 86949d5..e9c9f86 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -31,13 +31,13 @@ Name: %{?scl_prefix}gdb
# Freeze it when GDB gets branched
%global snapsrc 20200208
# See timestamp of source gnulib installed into gnulib/ .
-%global snapgnulib 20200630
+%global snapgnulib 20210105
%global tarname gdb-%{version}
-Version: 10.2
+Version: 11.1
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 6%{?dist}
+Release: 9%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
# Do not provide URL for snapshots as the file lasts there only for 2 days.
@@ -238,7 +238,7 @@ BuildRequires: /usr/bin/pod2man
%if 0%{!?rhel:1} || 0%{?rhel} > 7
BuildRequires: libbabeltrace-devel%{buildisa}
%if 0%{?rhel} < 9
-BuildRequires: guile-devel%{buildisa}
+BuildRequires: guile22-devel%{buildisa}
%endif
%endif
%global have_libipt 0
@@ -518,7 +518,7 @@ COMMON_GDB_CONFIGURE_FLAGS="\
--mandir=%{_mandir} \
--infodir=%{_infodir} \
--with-gdb-datadir=%{_datadir}/gdb \
- --enable-gdb-build-warnings=,-Wno-unused \
+ --enable-gdb-build-warnings=,-Wno-unused,-Wno-deprecated-declarations,-Wno-unused-function\
--enable-build-with-cxx \
%ifnarch %{ix86} alpha ppc s390 s390x x86_64 ppc64 ppc64le sparc sparcv9 sparc64 %{arm} aarch64
--disable-werror \
@@ -526,7 +526,7 @@ COMMON_GDB_CONFIGURE_FLAGS="\
--enable-werror \
%endif
--with-separate-debug-dir=/usr/lib/debug \
- --disable-sim \
+ --disable-sim \
--disable-rpath \
--without-stage1-ldflags \
--disable-libmcheck \
@@ -582,10 +582,11 @@ GDB_MINIMAL_CONFIGURE_FLAGS="\
--disable-unit-tests \
--disable-source-highlight"
-export CFLAGS="$RPM_OPT_FLAGS %{?_with_asan:-fsanitize=address}"
-export LDFLAGS="%{?__global_ldflags} %{?_with_asan:-fsanitize=address}"
-
-export CXXFLAGS="$CFLAGS"
+# Populate CFLAGS, LDFLAGS, CC, CXX, etc.
+%set_build_flags
+CFLAGS="$CFLAGS %{?_with_asan:-fsanitize=address}"
+LDFLAGS="$LDFLAGS %{?_with_asan:-fsanitize=address}"
+CXXFLAGS="$CXXFLAGS %{?_with_asan:-fsanitize=address}"
# --htmldir and --pdfdir are not used as they are used from %{gdb_build}.
../configure \
@@ -1143,7 +1144,81 @@ fi
%endif
%changelog
-* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org>
+* Wed Jan 12 2022 Alexandra Hájková - 11.1-9
+- Remove gdb-6.3-inferior-notification-20050721.patch
+ which adds problematic attach-32 test.
+
+* Tue Jan 11 2022 Alexandra Hájková - 11.1-8
+- Backport upstream patch "[PR gdb/27026] CTRL-C is ignored
+ when debug info is downloaded" (RHBZ 2024875, Aaron Merey).
+
+* Tue Jan 11 2022 Alexandra Hájková - 11.1-8
+- Backport upstream patch "rework "set debuginfod" commands"
+ (RHBZ 2024875, Simon Marchi).
+
+* Tue Jan 11 2022 Alexandra Hájková - 11.1-8
+- Backport upstream patch "Fix unittest.exp failure due to 'set debuginfod' addition"
+ (RHBZ 2024875, Tom Tromey).
+
+* Mon Jan 10 2022 Alexandra Hájková - 11.1-8
+- Add -Wno-unused-function to --enable-gdb-build-warnings to prevent the build failure:
+ "../../gdb/c-exp.y:3455:1: error: 'void c_print_token(FILE*, int, YYSTYPE)'
+ defined but not used [-Werror=unused-function]"
+
+* Mon Jan 10 2022 Alexandra Hájková - 11.1-8
+- Backport upstream patch "gdb: add set/show commands for managing debuginfod"
+ (RHBZ 2024875, Aaron Merey).
+
+* Mon Jan 10 2022 Alexandra Hájková - 11.1-8
+- Backport upstream patch "gdb.texinfo: Expand documentation for debuginfod"
+ (RHBZ 2024875, Aaron Merey).
+
+* Mon Dec 6 2021 Kevin Buettner - 11.1-7
+- Add -Wno-deprecated-declarations to --enable-gdb-build-warnings to work
+ around the python 3.11 deprecation of Py_SetProgramName.
+
+* Fri Nov 12 2021 Timm Bäder <tbaeder@redhat.com> - 11.1-6
+- Use %%set_build_flags to populate all relevant build flags
+
+* Wed Nov 10 2021 Kevin Buettner - 11.1-5
+- Backport upstream fix and test case for a dprintf bug (RHBZ 2022177, Kevin
+ Buettner).
+
+* Tue Nov 9 2021 Bruno Larsen - 11.1-4
+- Backport manpage update to be closer to -help (RHBZ 853071)
+
+* Wed Nov 3 2021 Kevin Buettner - 11.1-3
+- Make adjustments to gdb-6.6-buildid-locate.patch, provided by Tom de Vries.
+
+* Mon Oct 11 2021 Kevin Buettner - 11.1-2
+- Backport upstream patch which papers over Fortran lexical analyzer
+ bug (RHBZ 2012976, Tom de Vries).
+
+* Mon Oct 04 2021 Kevin Buettner - 11.1-1
+- Rebase to FSF GDB 11.1.
+- Adjust build-id related patches.
+- Drop backported patches which are no longer relevant.
+- Bump 'snapgnulib' date.
+
+* Thu Sep 30 2021 Alexandra Hájková <ahajkova@redhat.com> - 10.2-9
+- Backport test for RHBZ 1976887 (Kevin Buettner).
+
+* Thu Sep 30 2021 Alexandra Hájková <ahajkova@redhat.com> - 10.2-9
+- Backport upstream patch which fixes internal-error: Unexpected
+ type field location kind (RHBZ 1976887, Alexandra Hájková).
+
+* Wed Sep 22 2021 Bruno Larsen <blarsen@redhat.com> - 10.2-8
+- Backport "[gdb] Improve early exits for env var in debuginfod-support.c"
+ (Tom de Vries)
+
+* Wed Sep 22 2021 Bruno Larsen <blarsen@redhat.com> - 10.2-8
+- Backport "[gdb/cli] Don't assert on empty string for core-file"
+ (Tom de Vries)
+
+* Tue Sep 21 2021 Peter Robinson <pbrobinson@fedoraproject.org> 10.2-7
+- Use guile 2.2 (rhbz #1901353)
+
+* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> 10.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Tue Jul 20 2021 Kevin Buettner <kevinb@redhat.com> - 10.2-5
diff --git a/sources b/sources
index ecc7784..47a02e5 100644
--- a/sources
+++ b/sources
@@ -1,3 +1,3 @@
SHA512 (gdb-libstdc++-v3-python-8.1.1-20180626.tar.xz) = a8b1c54dd348cfeb37da73f968742896be3dd13a4215f8d8519870c2abea915f5176c3fa6989ddd10f20020a16f0fab20cbae68ee8d58a82234d8778023520f8
SHA512 (v2.0.4.tar.gz) = 596d2dac25fdbd3e5660d7e1feeb7e8d5d359d1d0e19b62ef593449037df236db1d4d98820f0031061b5573ed67797a85a77fb9991e215abaabc4bfe16ceaec8
-SHA512 (gdb-10.2.tar.xz) = 3653762ac008e065c37cd641653184c9ff7ce51ee2222ade1122bec9d6cc64dffd4fb74888ef11ac1942064a08910e96b7865112ad37f4602eb0a16bed074caa
+SHA512 (gdb-11.1.tar.xz) = c40bf970e2f7c2107b29c5aa6a7150daa709d75ddadb73ac20742419d4637d158e3063a4c6ff6e47fae8ca8e1d36253973f85ea15445d004be6d5d7a2dd9bd46
diff --git a/testing-custom-inputrc.patch b/testing-custom-inputrc.patch
deleted file mode 100644
index c95f7d1..0000000
--- a/testing-custom-inputrc.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Keith Seitz <keiths@redhat.com>
-Date: Tue, 23 Mar 2021 09:32:37 -0700
-Subject: testing-custom-inputrc.patch
-
-;; Backport "Disable bracketed paste mode in GDB tests"
-;; (Tom Tromey)
-
- commit 1af4c9c4209c3478224f18dfb79dc09567b96705
- Author: Tom Tromey <tom@tromey.com>
- Date: Sat Jan 23 08:52:45 2021 -0700
-
- Disable bracketed paste mode in GDB tests
-
- I have a patch to import GNU readline 8.1 into GDB. However, when
- running the tests, there were a number of failures due to "bracketed
- paste mode". This is a terminal feature that readline 8.1 enables by
- default.
-
- The simplest way to work around this was to always make a ".inputrc"
- for GDB tests that will tell readline to disable brackted paste mode.
-
- gdb/testsuite/ChangeLog
- 2021-01-23 Tom Tromey <tom@tromey.com>
-
- * lib/gdb.exp (default_gdb_init): Set INPUTRC to a cached file.
-
-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
-@@ -5135,13 +5135,14 @@ proc default_gdb_init { test_file_name } {
- setenv LC_CTYPE C
- setenv LANG C
-
-- # Don't let a .inputrc file or an existing setting of INPUTRC mess up
-- # the test results. Even if /dev/null doesn't exist on the particular
-- # platform, the readline library will use the default setting just by
-- # failing to open the file. OTOH, opening /dev/null successfully will
-- # also result in the default settings being used since nothing will be
-- # read from this file.
-- setenv INPUTRC "/dev/null"
-+ # Don't let a .inputrc file or an existing setting of INPUTRC mess
-+ # up the test results. Certain tests (style tests and TUI tests)
-+ # want to set the terminal to a non-"dumb" value, and for those we
-+ # want to disable bracketed paste mode. Versions of Readline
-+ # before 8.0 will not understand this and will issue a warning.
-+ # We tried using a $if to guard it, but Readline 8.1 had a bug in
-+ # its version-comparison code that prevented this for working.
-+ setenv INPUTRC [cached_file inputrc "set enable-bracketed-paste off"]
-
- # This disables style output, which would interfere with many
- # tests.
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-28 0:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-28 0:00 [rpms/gdb] gdb-17.2-rebase-f44: Merge #25 `tests/gdb-testsuite-sanity: add testcase` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox