From ba923a7799888aea0bb12842e4d4fe920e99ceaf Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Dec 15 2020 15:00:03 +0000 Subject: New upstream snapshot. Uses guile 2.2. --- diff --git a/.gitignore b/.gitignore index e39fa8c..de6866a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ insight-6.8-1.tar.bz2 /insight-8.1.50.20180216.tar.xz /insight-8.2.50.20190118.tar.xz /insight-10.0.50.20200110.tar.xz +/insight-11.0.50.20201215.tar.xz diff --git a/gdb-6.3-gstack-20050411.patch b/gdb-6.3-gstack-20050411.patch index 982863a..4413611 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 -@@ -1768,7 +1768,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force +@@ -1726,7 +1726,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 \ -@@ -1817,7 +1817,25 @@ install-guile: +@@ -1775,7 +1775,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 \ -@@ -1840,6 +1858,18 @@ uninstall: force $(CONFIG_UNINSTALL) +@@ -1798,6 +1816,18 @@ uninstall: force $(CONFIG_UNINSTALL) fi @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do diff --git a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch b/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch deleted file mode 100644 index a89de0a..0000000 --- a/gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch +++ /dev/null @@ -1,264 +0,0 @@ -From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Jan Kratochvil -Date: Fri, 27 Oct 2017 21:07:50 +0200 -Subject: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch - -;; Support TLS symbols (+`errno' suggestion if no pthread is found) (BZ 185337). -;;=push+jan: It should be replaced by Infinity project. - -https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337 - -2008-02-24 Jan Kratochvil - - Port to GDB-6.8pre. - -currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you -will get: - (gdb) p errno - [some error] - -* with -ggdb2 and less "errno" in fact does not exist anywhere as it was - compiled to "(*__errno_location ())" and the macro definition is not present. - Unfortunately gdb will find the TLS symbol and it will try to access it but - as the program has been compiled without -lpthread the TLS base register - (%gs on i386) is not setup and it will result in: - Cannot access memory at address 0x8 - -Attached suggestion patch how to deal with the most common "errno" symbol -for the most common under-ggdb3 compiled programs. - -Original patch hooked into target_translate_tls_address. But its inferior -call invalidates `struct frame *' in the callers - RH BZ 690908. - -https://bugzilla.redhat.com/show_bug.cgi?id=1166549 - -2007-11-03 Jan Kratochvil - - * ./gdb/dwarf2read.c (read_partial_die, dwarf2_linkage_name): Prefer - DW_AT_MIPS_linkage_name over DW_AT_name now only for non-C. - -glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug: - <81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location - <81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location - -diff --git a/gdb/printcmd.c b/gdb/printcmd.c ---- a/gdb/printcmd.c -+++ b/gdb/printcmd.c -@@ -1214,6 +1214,10 @@ print_command_1 (const char *args, int voidprint) - - if (exp != nullptr && *exp) - { -+ /* '*((int *(*) (void)) __errno_location) ()' is incompatible with -+ function descriptors. */ -+ if (target_has_execution && strcmp (exp, "errno") == 0) -+ exp = "*(*(int *(*)(void)) __errno_location) ()"; - expression_up expr = parse_expression (exp); - val = evaluate_expression (expr.get ()); - } -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-errno.c -@@ -0,0 +1,28 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2005, 2007 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . -+ -+ Please email any bugs, comments, and/or additions to this file to: -+ bug-gdb@prep.ai.mit.edu */ -+ -+#include -+ -+int main() -+{ -+ errno = 42; -+ -+ return 0; /* breakpoint */ -+} -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.exp b/gdb/testsuite/gdb.dwarf2/dw2-errno.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-errno.exp -@@ -0,0 +1,60 @@ -+# Copyright 2007 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+set testfile dw2-errno -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}] -+ -+proc prep {} { -+ global srcdir subdir binfile -+ gdb_exit -+ gdb_start -+ gdb_reinitialize_dir $srcdir/$subdir -+ gdb_load ${binfile} -+ -+ runto_main -+ -+ gdb_breakpoint [gdb_get_line_number "breakpoint"] -+ gdb_continue_to_breakpoint "breakpoint" -+} -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+prep -+gdb_test "print errno" ".* = 42" "errno with macros=N threads=N" -+ -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+prep -+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N" -+ -+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } { -+ return -1 -+} -+prep -+gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y" -+ -+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } { -+ return -1 -+} -+prep -+gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y" -+ -+# TODO: Test the error on resolving ERRNO with only libc loaded. -+# Just how to find the current libc filename? -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno2.c b/gdb/testsuite/gdb.dwarf2/dw2-errno2.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-errno2.c -@@ -0,0 +1,28 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2005, 2007 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . -+ -+ Please email any bugs, comments, and/or additions to this file to: -+ bug-gdb@prep.ai.mit.edu */ -+ -+#include -+ -+int main() -+{ -+ errno = 42; -+ -+ return 0; /* breakpoint */ -+} -diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp b/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp -@@ -0,0 +1,71 @@ -+# Copyright 2007 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+set testfile dw2-errno2 -+set srcfile ${testfile}.c -+set binfile [standard_output_file ${testfile}] -+ -+proc prep { message {do_xfail 0} } { with_test_prefix $message { -+ global srcdir subdir binfile variant -+ gdb_exit -+ gdb_start -+ gdb_reinitialize_dir $srcdir/$subdir -+ gdb_load ${binfile}${variant} -+ -+ runto_main -+ -+ gdb_breakpoint [gdb_get_line_number "breakpoint"] -+ gdb_continue_to_breakpoint "breakpoint" -+ -+ gdb_test "gcore ${binfile}${variant}.core" "\r\nSaved corefile .*" "gcore $variant" -+ -+ gdb_test "print errno" ".* = 42" -+ -+ gdb_test "kill" ".*" "kill" {Kill the program being debugged\? \(y or n\) } "y" -+ gdb_test "core-file ${binfile}${variant}.core" "\r\nCore was generated by .*" "core-file" -+ if $do_xfail { -+ setup_xfail "*-*-*" -+ } -+ gdb_test "print (int) errno" ".* = 42" "print errno for core" -+}} -+ -+set variant g2thrN -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g2"] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+prep "macros=N threads=N" 1 -+ -+set variant g3thrN -+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g3"] != "" } { -+ untested "Couldn't compile test program" -+ return -1 -+} -+prep "macros=Y threads=N" 1 -+ -+set variant g2thrY -+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g2"] != "" } { -+ return -1 -+} -+prep "macros=N threads=Y" -+ -+set variant g3thrY -+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g3"] != "" } { -+ return -1 -+} -+prep "macros=Y threads=Y" 1 -+ -+# TODO: Test the error on resolving ERRNO with only libc loaded. -+# Just how to find the current libc filename? diff --git a/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch b/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch index 0a66b3d..54c1a1e 100644 --- a/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch +++ b/gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch @@ -11,7 +11,7 @@ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379 diff --git a/gdb/symtab.c b/gdb/symtab.c --- a/gdb/symtab.c +++ b/gdb/symtab.c -@@ -3166,6 +3166,13 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) +@@ -3169,6 +3169,13 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) msymbol->linkage_name ()); */ ; /* fall through */ @@ -23,5 +23,5 @@ diff --git a/gdb/symtab.c b/gdb/symtab.c + warning ("In stub for %s (0x%s); interlocked, please submit the binary to http://bugzilla.redhat.com", msymbol.minsym->linkage_name (), paddress (target_gdbarch (), pc)); + /* fall through */ else - return find_pc_line (BMSYMBOL_VALUE_ADDRESS (mfunsym), 0); - } + { + /* Detect an obvious case of infinite recursion. If this diff --git a/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb-6.6-buildid-locate-core-as-arg.patch deleted file mode 100644 index d182ae1..0000000 --- a/gdb-6.6-buildid-locate-core-as-arg.patch +++ /dev/null @@ -1,196 +0,0 @@ -From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Fedora GDB patches -Date: Fri, 27 Oct 2017 21:07:50 +0200 -Subject: gdb-6.6-buildid-locate-core-as-arg.patch - -;;=push+jan - -http://sourceware.org/ml/gdb-patches/2010-01/msg00558.html - -[ Fixed up since the mail. ] - -On Thu, 21 Jan 2010 18:17:15 +0100, Doug Evans wrote: -> Not an exhaustive list, but if we go down the path of converting "gdb -> corefile" to "gdb -c corefile", then we also need to think about "file -> corefile" being converted to "core corefile" [or "target core -> corefile", "core" is apparently deprecated in favor of "target core"] -> and "target exec corefile" -> "target core corefile". Presumably -> "file corefile" (and "target exec corefile") would discard the -> currently selected executable. But maybe not. Will that be confusing -> for users? I don't know. - -While thinking about it overriding some GDB _commands_ was not my intention. - -There is a general assumption if I have a shell COMMAND and some FILE I can do -$ COMMAND FILE -and COMMAND will appropriately load the FILE. - -FSF GDB currently needs to specify also the executable file for core files -which already inhibits this intuitive expectation. OTOH with the build-id -locating patch which could allow such intuitive start notneeding the -executable file. Still it currently did not work due to the required "-c": -$ COMMAND -c COREFILE - -Entering "file", "core-file" or "attach" commands is already explicit enough -so that it IMO should do what the command name says without any -autodetections. The second command line argument -(captured_main->pid_or_core_arg) is also autodetected (for PID or CORE) but -neither "attach" accepts a core file nor "core-file" accepts a PID. - -The patch makes sense only with the build-id patchset so this is not submit -for FSF GDB inclusion yet. I am fine with your patch (+/- Hui Zhu's pending -bfd_check_format_matches) as the patch below is its natural extension. - -Sorry for the delay, -Jan - -2010-01-25 Jan Kratochvil - - * exceptions.h (enum errors ): New. - * exec.c: Include exceptions.h. - (exec_file_attach ): Call throw_error (IS_CORE_ERROR, ...). - * main.c (exec_or_core_file_attach): New. - (captured_main ): Set also corearg. - (captured_main ): New variable func. - Call exec_or_core_file_attach if COREARG matches EXECARG. Call - symbol_file_add_main only if CORE_BFD remained NULL. - -Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html -2010-01-20 Doug Evans - - * exec.c (exec_file_attach): Print a more useful error message if the - user did "gdb core". - -diff --git a/gdb/exec.c b/gdb/exec.c ---- a/gdb/exec.c -+++ b/gdb/exec.c -@@ -18,6 +18,8 @@ - along with this program. If not, see . */ - - #include "defs.h" -+#include "arch-utils.h" -+#include "exceptions.h" - #include "frame.h" - #include "inferior.h" - #include "target.h" -@@ -345,12 +347,27 @@ exec_file_attach (const char *filename, int from_tty) - - if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) - { -+ int is_core; -+ -+ /* If the user accidentally did "gdb core", print a useful -+ error message. Check it only after bfd_object has been checked as -+ a valid executable may get recognized for example also as -+ "trad-core". */ -+ is_core = bfd_check_format (exec_bfd, bfd_core); -+ - /* Make sure to close exec_bfd, or else "run" might try to use - it. */ - exec_close (); -- error (_("\"%s\": not in executable format: %s"), -- scratch_pathname, -- gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); -+ -+ if (is_core != 0) -+ throw_error (IS_CORE_ERROR, -+ _("\"%s\" is a core file.\n" -+ "Please specify an executable to debug."), -+ scratch_pathname); -+ else -+ error (_("\"%ss\": not in executable format: %s"), -+ scratch_pathname, -+ gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); - } - - if (build_section_table (exec_bfd, §ions, §ions_end)) -diff --git a/gdb/gdbsupport/common-exceptions.h b/gdb/gdbsupport/common-exceptions.h ---- a/gdb/gdbsupport/common-exceptions.h -+++ b/gdb/gdbsupport/common-exceptions.h -@@ -106,6 +106,9 @@ enum errors { - "_ERROR" is appended to the name. */ - MAX_COMPLETIONS_REACHED_ERROR, - -+ /* Attempt to load a core file as executable. */ -+ IS_CORE_ERROR, -+ - /* Add more errors here. */ - NR_ERRORS - }; -diff --git a/gdb/main.c b/gdb/main.c ---- a/gdb/main.c -+++ b/gdb/main.c -@@ -467,6 +467,34 @@ struct cmdarg - char *string; - }; - -+/* Call exec_file_attach. If it detected FILENAME is a core file call -+ core_file_command. Print the original exec_file_attach error only if -+ core_file_command failed to find a matching executable. */ -+ -+static void -+exec_or_core_file_attach (const char *filename, int from_tty) -+{ -+ gdb_assert (exec_bfd == NULL); -+ -+ try -+ { -+ exec_file_attach (filename, from_tty); -+ } -+ catch (gdb_exception_error &e) -+ { -+ if (e.error == IS_CORE_ERROR) -+ { -+ core_file_command ((char *) filename, from_tty); -+ -+ /* Iff the core file found its executable suppress the error message -+ from exec_file_attach. */ -+ if (exec_bfd != NULL) -+ return; -+ } -+ throw_exception (std::move (e)); -+ } -+} -+ - static void - captured_main_1 (struct captured_main_args *context) - { -@@ -907,6 +935,8 @@ captured_main_1 (struct captured_main_args *context) - { - symarg = argv[optind]; - execarg = argv[optind]; -+ if (optind + 1 == argc && corearg == NULL) -+ corearg = argv[optind]; - optind++; - } - -@@ -1063,12 +1093,25 @@ captured_main_1 (struct captured_main_args *context) - && symarg != NULL - && strcmp (execarg, symarg) == 0) - { -+ catch_command_errors_const_ftype *func; -+ -+ /* Call exec_or_core_file_attach only if the file was specified as -+ a command line argument (and not an a command line option). */ -+ if (corearg != NULL && strcmp (corearg, execarg) == 0) -+ { -+ func = exec_or_core_file_attach; -+ corearg = NULL; -+ } -+ else -+ func = exec_file_attach; -+ - /* The exec file and the symbol-file are the same. If we can't - open it, better only print one error message. -- catch_command_errors returns non-zero on success! */ -- ret = catch_command_errors (exec_file_attach, execarg, -- !batch_flag); -- if (ret != 0) -+ catch_command_errors returns non-zero on success! -+ Do not load EXECARG as a symbol file if it has been already processed -+ as a core file. */ -+ ret = catch_command_errors (func, execarg, !batch_flag); -+ if (ret != 0 && core_bfd == NULL) - ret = catch_command_errors (symbol_file_add_main_adapter, - symarg, !batch_flag); - } diff --git a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch index abea6e6..c86ec6b 100644 --- a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch +++ b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch @@ -9,7 +9,7 @@ Subject: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch diff --git a/gdb/build-id.c b/gdb/build-id.c --- a/gdb/build-id.c +++ b/gdb/build-id.c -@@ -709,6 +709,19 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return) +@@ -708,6 +708,19 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return) #include #endif diff --git a/gdb-6.6-buildid-locate-rpm-scl.patch b/gdb-6.6-buildid-locate-rpm-scl.patch index ca683ed..09f930f 100644 --- a/gdb-6.6-buildid-locate-rpm-scl.patch +++ b/gdb-6.6-buildid-locate-rpm-scl.patch @@ -12,7 +12,7 @@ https://bugzilla.redhat.com/show_bug.cgi?id=953585 diff --git a/gdb/build-id.c b/gdb/build-id.c --- a/gdb/build-id.c +++ b/gdb/build-id.c -@@ -743,7 +743,11 @@ static int missing_rpm_list_entries; +@@ -742,7 +742,11 @@ static int missing_rpm_list_entries; /* Returns the count of newly added rpms. */ static int @@ -24,7 +24,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c { static int rpm_init_done = 0; rpmts ts; -@@ -850,7 +854,11 @@ missing_rpm_enlist (const char *filename) +@@ -849,7 +853,11 @@ missing_rpm_enlist (const char *filename) mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0); if (mi != NULL) { @@ -36,7 +36,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c { Header h; char *debuginfo, **slot, *s, *s2; -@@ -968,6 +976,37 @@ missing_rpm_enlist (const char *filename) +@@ -967,6 +975,37 @@ missing_rpm_enlist (const char *filename) xfree (debuginfo); count++; } @@ -74,7 +74,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c rpmdbFreeIterator_p (mi); } -@@ -977,6 +1016,20 @@ missing_rpm_enlist (const char *filename) +@@ -976,6 +1015,20 @@ missing_rpm_enlist (const char *filename) return count; } @@ -95,10 +95,10 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c static bool missing_rpm_list_compar (const char *ap, const char *bp) { -diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -3497,6 +3497,16 @@ read_gdb_index_from_buffer (struct objfile *objfile, +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -3025,6 +3025,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/dwarf2read.c b/gdb/dwarf2read.c static int warning_printed = 0; if (!warning_printed) { -@@ -3508,6 +3518,10 @@ to use the section anyway."), +@@ -3036,6 +3046,10 @@ to use the section anyway."), warning_printed = 1; } return 0; diff --git a/gdb-6.6-buildid-locate-solib-missing-ids.patch b/gdb-6.6-buildid-locate-solib-missing-ids.patch deleted file mode 100644 index 73b763a..0000000 --- a/gdb-6.6-buildid-locate-solib-missing-ids.patch +++ /dev/null @@ -1,237 +0,0 @@ -From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Fedora GDB patches -Date: Fri, 27 Oct 2017 21:07:50 +0200 -Subject: gdb-6.6-buildid-locate-solib-missing-ids.patch - -;; Fix loading of core files without build-ids but with build-ids in executables. -;; Load strictly build-id-checked core files only if no executable is specified -;; (Jan Kratochvil, RH BZ 1339862). -;;=push+jan - -gdb returns an incorrect back trace when applying a debuginfo -https://bugzilla.redhat.com/show_bug.cgi?id=1339862 - -diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c ---- a/gdb/solib-svr4.c -+++ b/gdb/solib-svr4.c -@@ -1346,14 +1346,27 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, - } - - { -- struct bfd_build_id *build_id; -+ struct bfd_build_id *build_id = NULL; - - strncpy (newobj->so_original_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1); - newobj->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; - /* May get overwritten below. */ - strcpy (newobj->so_name, newobj->so_original_name); - -- build_id = build_id_addr_get (((lm_info_svr4 *) newobj->lm_info)->l_ld); -+ /* In the case the main executable was found according to its build-id -+ (from a core file) prevent loading a different build of a library -+ with accidentally the same SO_NAME. -+ -+ It suppresses bogus backtraces (and prints "??" there instead) if -+ the on-disk files no longer match the running program version. -+ -+ If the main executable was not loaded according to its build-id do -+ not do any build-id checking of the libraries. There may be missing -+ build-ids dumped in the core file and we would map all the libraries -+ to the only existing file loaded that time - the executable. */ -+ if (symfile_objfile != NULL -+ && (symfile_objfile->flags & OBJF_BUILD_ID_CORE_LOADED) != 0) -+ build_id = build_id_addr_get (li->l_ld); - if (build_id != NULL) - { - char *name, *build_id_filename; -@@ -1368,23 +1381,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, - xfree (name); - } - else -- { -- debug_print_missing (newobj->so_name, build_id_filename); -- -- /* In the case the main executable was found according to -- its build-id (from a core file) prevent loading -- a different build of a library with accidentally the -- same SO_NAME. -- -- It suppresses bogus backtraces (and prints "??" there -- instead) if the on-disk files no longer match the -- running program version. */ -- -- if (symfile_objfile != NULL -- && (symfile_objfile->flags -- & OBJF_BUILD_ID_CORE_LOADED) != 0) -- newobj->so_name[0] = 0; -- } -+ debug_print_missing (newobj->so_name, build_id_filename); - - xfree (build_id_filename); - xfree (build_id); -diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c -@@ -0,0 +1,21 @@ -+/* Copyright 2010 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+void -+lib (void) -+{ -+} -diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c -@@ -0,0 +1,25 @@ -+/* Copyright 2010 Free Software Foundation, Inc. -+ -+ This file is part of GDB. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+extern void lib (void); -+ -+int -+main (void) -+{ -+ lib (); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp -@@ -0,0 +1,105 @@ -+# Copyright 2016 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+if {[skip_shlib_tests]} { -+ return 0 -+} -+ -+set testfile "gcore-buildid-exec-but-not-solib" -+set srcmainfile ${testfile}-main.c -+set srclibfile ${testfile}-lib.c -+set libfile [standard_output_file ${testfile}-lib.so] -+set objfile [standard_output_file ${testfile}-main.o] -+set executable ${testfile}-main -+set binfile [standard_output_file ${executable}] -+set gcorefile [standard_output_file ${executable}.gcore] -+set outdir [file dirname $binfile] -+ -+if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} "debug additional_flags=-Wl,--build-id"] != "" -+ || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } { -+ unsupported "-Wl,--build-id compilation failed" -+ return -1 -+} -+set opts [list debug shlib=${libfile} "additional_flags=-Wl,--build-id"] -+if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } { -+ unsupported "-Wl,--build-id compilation failed" -+ return -1 -+} -+ -+clean_restart $executable -+gdb_load_shlib $libfile -+ -+# Does this gdb support gcore? -+set test "help gcore" -+gdb_test_multiple $test $test { -+ -re "Undefined command: .gcore.*\r\n$gdb_prompt $" { -+ # gcore command not supported -- nothing to test here. -+ unsupported "gdb does not support gcore on this target" -+ return -1; -+ } -+ -re "Save a core file .*\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+if { ![runto lib] } then { -+ return -1 -+} -+ -+set escapedfilename [string_to_regexp ${gcorefile}] -+ -+set test "save a corefile" -+gdb_test_multiple "gcore ${gcorefile}" $test { -+ -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "Can't create a corefile\r\n$gdb_prompt $" { -+ unsupported $test -+ return -1 -+ } -+} -+ -+# Now restart gdb and load the corefile. -+ -+clean_restart $executable -+gdb_load_shlib $libfile -+ -+set buildid [build_id_debug_filename_get $libfile] -+ -+regsub {\.debug$} $buildid {} buildid -+ -+set debugdir [standard_output_file ${testfile}-debugdir] -+file delete -force -- $debugdir -+ -+file mkdir $debugdir/[file dirname $libfile] -+file copy $libfile $debugdir/${libfile} -+ -+file mkdir $debugdir/[file dirname $buildid] -+file copy $libfile $debugdir/${buildid} -+ -+remote_exec build "ln -s /lib ${debugdir}/" -+remote_exec build "ln -s /lib64 ${debugdir}/" -+# /usr is not needed, all the libs are in /lib64: libm.so.6 libc.so.6 ld-linux-x86-64.so.2 -+ -+gdb_test "set solib-absolute-prefix $debugdir" -+ -+gdb_test_no_output "set debug-file-directory $debugdir" "set debug-file-directory" -+ -+gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile" -+ -+gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded" -+ -+gdb_test "bt" -+gdb_test "info shared" diff --git a/gdb-6.8-quit-never-aborts.patch b/gdb-6.8-quit-never-aborts.patch index 4dd01c5..a682469 100644 --- a/gdb-6.8-quit-never-aborts.patch +++ b/gdb-6.8-quit-never-aborts.patch @@ -16,7 +16,7 @@ on the debugger termination). diff --git a/gdb/defs.h b/gdb/defs.h --- a/gdb/defs.h +++ b/gdb/defs.h -@@ -168,6 +168,10 @@ extern void default_quit_handler (void); +@@ -177,6 +177,10 @@ extern void default_quit_handler (void); /* Flag that function quit should call quit_force. */ extern volatile int sync_quit_force_run; @@ -30,24 +30,24 @@ diff --git a/gdb/defs.h b/gdb/defs.h diff --git a/gdb/extension.c b/gdb/extension.c --- a/gdb/extension.c +++ b/gdb/extension.c -@@ -823,6 +823,11 @@ check_quit_flag (void) - int i, result = 0; - const struct extension_language_defn *extlang; +@@ -769,6 +769,11 @@ check_quit_flag (void) + { + int result = 0; +#ifdef NEED_DETACH_SIGSTOP + if (quit_flag_cleanup) + return 0; +#endif + - ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang) + for (const struct extension_language_defn *extlang : extension_languages) { - if (extlang->ops->check_quit_flag != NULL) + if (extlang->ops != nullptr diff --git a/gdb/top.c b/gdb/top.c --- a/gdb/top.c +++ b/gdb/top.c -@@ -1703,7 +1703,13 @@ quit_force (int *exit_arg, int from_tty) - - qt.from_tty = from_tty; +@@ -1770,7 +1770,13 @@ quit_force (int *exit_arg, int from_tty) + else if (return_child_result) + exit_code = return_child_result_value; +#ifndef NEED_DETACH_SIGSTOP /* We want to handle any quit errors and exit regardless. */ @@ -62,7 +62,7 @@ diff --git a/gdb/top.c b/gdb/top.c diff --git a/gdb/utils.c b/gdb/utils.c --- a/gdb/utils.c +++ b/gdb/utils.c -@@ -102,6 +102,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time; +@@ -103,6 +103,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time; static bool debug_timestamp = false; diff --git a/gdb-archer-pie-addons-keep-disabled.patch b/gdb-archer-pie-addons-keep-disabled.patch new file mode 100644 index 0000000..ed02f2c --- /dev/null +++ b/gdb-archer-pie-addons-keep-disabled.patch @@ -0,0 +1,89 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Fedora GDB patches +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-archer-pie-addons-keep-disabled.patch + +;;=push+jan: Breakpoints disabling matching should not be based on address. + +diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c +--- a/gdb/breakpoint.c ++++ b/gdb/breakpoint.c +@@ -15431,6 +15431,50 @@ static struct cmd_list_element *enablebreaklist = NULL; + + cmd_list_element *commands_cmd_element = nullptr; + ++void ++breakpoints_relocate (struct objfile *objfile, section_offsets &delta) ++{ ++ struct bp_location *bl, **blp_tmp; ++ int changed = 0; ++ ++ gdb_assert (objfile->separate_debug_objfile_backlink == NULL); ++ ++ ALL_BP_LOCATIONS (bl, blp_tmp) ++ { ++ struct obj_section *osect; ++ ++ /* BL->SECTION can be correctly NULL for breakpoints with multiple ++ locations expanded through symtab. */ ++ ++ ALL_OBJFILE_OSECTIONS (objfile, osect) ++ { ++ CORE_ADDR relocated_address; ++ CORE_ADDR delta_offset; ++ ++ delta_offset = delta[osect->the_bfd_section->index]; ++ if (delta_offset == 0) ++ continue; ++ relocated_address = bl->address + delta_offset; ++ ++ if (obj_section_addr (osect) <= relocated_address ++ && relocated_address < obj_section_endaddr (osect)) ++ { ++ if (bl->inserted) ++ remove_breakpoint (bl); ++ ++ bl->address += delta_offset; ++ bl->requested_address += delta_offset; ++ ++ changed = 1; ++ } ++ } ++ } ++ ++ if (changed) ++ std::sort (bp_locations, bp_locations + bp_locations_count, ++ bp_location_is_less_than); ++} ++ + void _initialize_breakpoint (); + void + _initialize_breakpoint () +diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h +--- a/gdb/breakpoint.h ++++ b/gdb/breakpoint.h +@@ -1691,6 +1691,9 @@ extern const char *ep_parse_optional_if_clause (const char **arg); + UIOUT iff debugging multiple threads. */ + extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout); + ++extern void breakpoints_relocate (struct objfile *objfile, ++ section_offsets &delta); ++ + /* Print the specified breakpoint. */ + extern void print_breakpoint (breakpoint *bp); + +diff --git a/gdb/objfiles.c b/gdb/objfiles.c +--- a/gdb/objfiles.c ++++ b/gdb/objfiles.c +@@ -742,6 +742,11 @@ objfile_relocate1 (struct objfile *objfile, + obj_section_addr (s)); + } + ++ /* Final call of breakpoint_re_set can keep breakpoint locations disabled if ++ their addresses match. */ ++ if (objfile->separate_debug_objfile_backlink == NULL) ++ breakpoints_relocate (objfile, delta); ++ + /* Data changed. */ + return 1; + } diff --git a/gdb-archer-pie-addons.patch b/gdb-archer-pie-addons.patch index e3af3a9..f0c68db 100644 --- a/gdb-archer-pie-addons.patch +++ b/gdb-archer-pie-addons.patch @@ -8,7 +8,7 @@ Subject: gdb-archer-pie-addons.patch diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h -@@ -516,6 +516,7 @@ enum field_loc_kind +@@ -649,6 +649,7 @@ enum field_loc_kind { FIELD_LOC_KIND_BITPOS, /**< bitpos */ FIELD_LOC_KIND_ENUMVAL, /**< enumval */ @@ -16,7 +16,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h FIELD_LOC_KIND_PHYSADDR, /**< physaddr */ FIELD_LOC_KIND_PHYSNAME, /**< physname */ FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */ -@@ -566,6 +567,7 @@ union field_location +@@ -699,6 +700,7 @@ union field_location field. Otherwise, physname is the mangled label of the static field. */ @@ -24,37 +24,13 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h CORE_ADDR physaddr; const char *physname; -@@ -1474,6 +1476,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); - #define FIELD_ENUMVAL_LVAL(thisfld) ((thisfld).loc.enumval) - #define FIELD_ENUMVAL(thisfld) (FIELD_ENUMVAL_LVAL (thisfld) + 0) - #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname) -+/* This address is unrelocated by the objfile's ANOFFSET. */ - #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr) - #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block) - #define SET_FIELD_BITPOS(thisfld, bitpos) \ -@@ -1485,6 +1488,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); - #define SET_FIELD_PHYSNAME(thisfld, name) \ - (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME, \ - FIELD_STATIC_PHYSNAME (thisfld) = (name)) -+/* This address is unrelocated by the objfile's ANOFFSET. */ - #define SET_FIELD_PHYSADDR(thisfld, addr) \ - (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \ - FIELD_STATIC_PHYSADDR (thisfld) = (addr)) -@@ -1501,6 +1505,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); - #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n)) -+/* This address is unrelocated by the objfile's ANOFFSET. */ - #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n)) - #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n)) diff --git a/gdb/value.c b/gdb/value.c --- a/gdb/value.c +++ b/gdb/value.c -@@ -2839,7 +2839,8 @@ value_static_field (struct type *type, int fieldno) +@@ -2850,7 +2850,8 @@ value_static_field (struct type *type, int fieldno) { case FIELD_LOC_KIND_PHYSADDR: - retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno), + retval = value_at_lazy (type->field (fieldno).type (), - TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)); + TYPE_FIELD_STATIC_PHYSADDR (type, fieldno) + + (TYPE_OBJFILE (type) == NULL ? 0 : TYPE_OBJFILE (type)->section_offsets[SECT_OFF_TEXT (TYPE_OBJFILE (type))])); diff --git a/gdb-attach-fail-reasons-5of5.patch b/gdb-attach-fail-reasons-5of5.patch index 5b3b6d3..8830be3 100644 --- a/gdb-attach-fail-reasons-5of5.patch +++ b/gdb-attach-fail-reasons-5of5.patch @@ -45,7 +45,7 @@ gdb/gdbserver/ diff --git a/gdb/config.in b/gdb/config.in --- a/gdb/config.in +++ b/gdb/config.in -@@ -251,6 +251,9 @@ +@@ -253,6 +253,9 @@ /* Define if librpm library is being used. */ #undef HAVE_LIBRPM @@ -55,7 +55,7 @@ diff --git a/gdb/config.in b/gdb/config.in /* Define to 1 if you have the header file. */ #undef HAVE_LIBUNWIND_IA64_H -@@ -386,6 +389,9 @@ +@@ -388,6 +391,9 @@ /* Define to 1 if you have the `scm_new_smob' function. */ #undef HAVE_SCM_NEW_SMOB @@ -68,7 +68,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 -@@ -16434,6 +16434,64 @@ cat >>confdefs.h <<_ACEOF +@@ -16861,6 +16861,64 @@ cat >>confdefs.h <<_ACEOF _ACEOF @@ -136,7 +136,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 -@@ -1964,6 +1964,10 @@ case $host_os in +@@ -1900,6 +1900,10 @@ case $host_os in esac AC_DEFINE_UNQUOTED(GDBINIT,"$gdbinit",[The .gdbinit filename.]) @@ -147,12 +147,93 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac dnl Handle optional features that can be enabled. # Support for --with-sysroot is a copy of GDB_AC_WITH_DIR, -diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in ---- a/gdb/gdbserver/config.in -+++ b/gdb/gdbserver/config.in -@@ -125,6 +125,9 @@ - /* Define to 1 if you have the `dl' library (-ldl). */ - #undef HAVE_LIBDL +diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c +--- a/gdb/linux-nat.c ++++ b/gdb/linux-nat.c +@@ -1103,7 +1103,16 @@ linux_nat_target::create_inferior (const char *exec_file, + /* Make sure we report all signals during startup. */ + pass_signals ({}); + +- inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty); ++ try ++ { ++ inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty); ++ } ++ catch (const gdb_exception_error &ex) ++ { ++ std::string result = linux_ptrace_create_warnings (); ++ ++ throw_error (ex.error, "%s%s", result.c_str (), ex.message->c_str ()); ++ } + } + + /* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not +diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c +--- a/gdb/nat/linux-ptrace.c ++++ b/gdb/nat/linux-ptrace.c +@@ -25,6 +25,10 @@ + #include + #endif + ++#ifdef HAVE_SELINUX_SELINUX_H ++# include ++#endif /* HAVE_SELINUX_SELINUX_H */ ++ + /* Stores the ptrace options supported by the running kernel. + A value of -1 means we did not check for features yet. A value + of 0 means there are no supported features. */ +@@ -50,6 +54,8 @@ linux_ptrace_attach_fail_reason (pid_t pid) + "terminated"), + (int) pid); + ++ result += linux_ptrace_create_warnings (); ++ + return result; + } + +@@ -586,6 +592,25 @@ linux_ptrace_init_warnings (void) + linux_ptrace_test_ret_to_nx (); + } + ++/* Print all possible reasons we could fail to create a traced process. */ ++ ++std::string ++linux_ptrace_create_warnings () ++{ ++ std::string result; ++ ++#ifdef HAVE_LIBSELINUX ++ /* -1 is returned for errors, 0 if it has no effect, 1 if PTRACE_ATTACH is ++ forbidden. */ ++ if (security_get_boolean_active ("deny_ptrace") == 1) ++ string_appendf (result, ++ _("the SELinux boolean 'deny_ptrace' is enabled, " ++ "you can disable this process attach protection by: " ++ "(gdb) shell sudo setsebool deny_ptrace=0\n")); ++#endif /* HAVE_LIBSELINUX */ ++ return result; ++} ++ + /* Extract extended ptrace event from wait status. */ + + int +diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h +--- a/gdb/nat/linux-ptrace.h ++++ b/gdb/nat/linux-ptrace.h +@@ -184,6 +184,7 @@ extern std::string linux_ptrace_attach_fail_reason (pid_t pid); + extern std::string linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err); + + extern void linux_ptrace_init_warnings (void); ++extern std::string linux_ptrace_create_warnings (); + extern void linux_check_ptrace_features (void); + extern void linux_enable_event_reporting (pid_t pid, int attached); + extern void linux_disable_event_reporting (pid_t pid); +diff --git a/gdbserver/config.in b/gdbserver/config.in +--- a/gdbserver/config.in ++++ b/gdbserver/config.in +@@ -143,6 +143,9 @@ + /* Define if you have the ipt library. */ + #undef HAVE_LIBIPT +/* Define to 1 if you have the `selinux' library (-lselinux). */ +#undef HAVE_LIBSELINUX @@ -160,9 +241,9 @@ diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in /* Define if the target supports branch tracing. */ #undef HAVE_LINUX_BTRACE -@@ -210,6 +213,9 @@ - /* Define to 1 if you have the `pwrite' function. */ - #undef HAVE_PWRITE +@@ -249,6 +252,9 @@ + /* Define to 1 if you have the `sbrk' function. */ + #undef HAVE_SBRK +/* Define to 1 if you have the header file. */ +#undef HAVE_SELINUX_SELINUX_H @@ -170,10 +251,10 @@ diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in /* Define to 1 if you have the `setns' function. */ #undef HAVE_SETNS -diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure ---- a/gdb/gdbserver/configure -+++ b/gdb/gdbserver/configure -@@ -9398,6 +9398,64 @@ if $want_ipa ; then +diff --git a/gdbserver/configure b/gdbserver/configure +--- a/gdbserver/configure ++++ b/gdbserver/configure +@@ -10683,6 +10683,64 @@ if $want_ipa ; then fi fi @@ -238,10 +319,10 @@ diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure -diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac ---- a/gdb/gdbserver/configure.ac -+++ b/gdb/gdbserver/configure.ac -@@ -465,6 +465,10 @@ if $want_ipa ; then +diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac +--- a/gdbserver/configure.ac ++++ b/gdbserver/configure.ac +@@ -401,6 +401,10 @@ if $want_ipa ; then fi fi @@ -252,10 +333,10 @@ diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac AC_SUBST(GDBSERVER_DEPFILES) AC_SUBST(GDBSERVER_LIBS) AC_SUBST(srv_xmlbuiltin) -diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c ---- a/gdb/gdbserver/linux-low.c -+++ b/gdb/gdbserver/linux-low.c -@@ -968,7 +968,16 @@ linux_ptrace_fun () +diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc +--- a/gdbserver/linux-low.cc ++++ b/gdbserver/linux-low.cc +@@ -932,7 +932,16 @@ linux_ptrace_fun () { if (ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0) < 0) @@ -273,84 +354,3 @@ diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c if (setpgid (0, 0) < 0) trace_start_error_with_name ("setpgid"); -diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c ---- a/gdb/linux-nat.c -+++ b/gdb/linux-nat.c -@@ -1092,7 +1092,16 @@ linux_nat_target::create_inferior (const char *exec_file, - /* Make sure we report all signals during startup. */ - pass_signals ({}); - -- inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty); -+ try -+ { -+ inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty); -+ } -+ catch (const gdb_exception_error &ex) -+ { -+ std::string result = linux_ptrace_create_warnings (); -+ -+ throw_error (ex.error, "%s%s", result.c_str (), ex.message->c_str ()); -+ } - } - - /* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not -diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c ---- a/gdb/nat/linux-ptrace.c -+++ b/gdb/nat/linux-ptrace.c -@@ -25,6 +25,10 @@ - #include - #endif - -+#ifdef HAVE_SELINUX_SELINUX_H -+# include -+#endif /* HAVE_SELINUX_SELINUX_H */ -+ - /* Stores the ptrace options supported by the running kernel. - A value of -1 means we did not check for features yet. A value - of 0 means there are no supported features. */ -@@ -50,6 +54,8 @@ linux_ptrace_attach_fail_reason (pid_t pid) - "terminated"), - (int) pid); - -+ result += linux_ptrace_create_warnings (); -+ - return result; - } - -@@ -586,6 +592,25 @@ linux_ptrace_init_warnings (void) - linux_ptrace_test_ret_to_nx (); - } - -+/* Print all possible reasons we could fail to create a traced process. */ -+ -+std::string -+linux_ptrace_create_warnings () -+{ -+ std::string result; -+ -+#ifdef HAVE_LIBSELINUX -+ /* -1 is returned for errors, 0 if it has no effect, 1 if PTRACE_ATTACH is -+ forbidden. */ -+ if (security_get_boolean_active ("deny_ptrace") == 1) -+ string_appendf (result, -+ _("the SELinux boolean 'deny_ptrace' is enabled, " -+ "you can disable this process attach protection by: " -+ "(gdb) shell sudo setsebool deny_ptrace=0\n")); -+#endif /* HAVE_LIBSELINUX */ -+ return result; -+} -+ - /* Extract extended ptrace event from wait status. */ - - int -diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h ---- a/gdb/nat/linux-ptrace.h -+++ b/gdb/nat/linux-ptrace.h -@@ -184,6 +184,7 @@ extern std::string linux_ptrace_attach_fail_reason (pid_t pid); - extern std::string linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err); - - extern void linux_ptrace_init_warnings (void); -+extern std::string linux_ptrace_create_warnings (); - extern void linux_check_ptrace_features (void); - extern void linux_enable_event_reporting (pid_t pid, int attached); - extern void linux_disable_event_reporting (pid_t pid); diff --git a/gdb-bz1219747-attach-kills.patch b/gdb-bz1219747-attach-kills.patch index 69c8658..fb3a349 100644 --- a/gdb-bz1219747-attach-kills.patch +++ b/gdb-bz1219747-attach-kills.patch @@ -80,7 +80,7 @@ gdb/testsuite/ChangeLog diff --git a/gdb/main.c b/gdb/main.c --- a/gdb/main.c +++ b/gdb/main.c -@@ -1148,7 +1148,10 @@ captured_main_1 (struct captured_main_args *context) +@@ -1199,7 +1199,10 @@ captured_main_1 (struct captured_main_args *context) { ret = catch_command_errors (attach_command, pid_or_core_arg, !batch_flag); diff --git a/gdb-bz533176-fortran-omp-step.patch b/gdb-bz533176-fortran-omp-step.patch index ee426ce..5264115 100644 --- a/gdb-bz533176-fortran-omp-step.patch +++ b/gdb-bz533176-fortran-omp-step.patch @@ -30,7 +30,7 @@ debugging problem of GOMP outside of the scope of this Bug. diff --git a/gdb/infrun.c b/gdb/infrun.c --- a/gdb/infrun.c +++ b/gdb/infrun.c -@@ -6453,6 +6453,16 @@ process_event_stop_test (struct execution_control_state *ecs) +@@ -6788,6 +6788,16 @@ process_event_stop_test (struct execution_control_state *ecs) if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL) { @@ -47,7 +47,7 @@ diff --git a/gdb/infrun.c b/gdb/infrun.c /* We're doing a "next". Normal (forward) execution: set a breakpoint at the -@@ -6486,6 +6496,7 @@ process_event_stop_test (struct execution_control_state *ecs) +@@ -6821,6 +6831,7 @@ process_event_stop_test (struct execution_control_state *ecs) keep_going (ecs); return; diff --git a/gdb-container-rh-pkg.patch b/gdb-container-rh-pkg.patch index b095d4b..04a7f3c 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 -@@ -13916,7 +13916,17 @@ remote_target::pid_to_exec_file (int pid) +@@ -14031,7 +14031,17 @@ remote_target::pid_to_exec_file (int pid) char *annex = NULL; if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE) @@ -26,5 +26,5 @@ diff --git a/gdb/remote.c b/gdb/remote.c + return NULL; + } - inf = find_inferior_pid (pid); + inferior *inf = find_inferior_pid (this, pid); if (inf == NULL) diff --git a/gdb-fedora-libncursesw.patch b/gdb-fedora-libncursesw.patch index 960193f..7c620fb 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 -@@ -9375,6 +9375,7 @@ if test x"$prefer_curses" = xyes; then +@@ -9649,6 +9649,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 : -@@ -9399,7 +9400,7 @@ return waddstr (); +@@ -9673,7 +9674,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 -@@ -9473,6 +9474,7 @@ case $host_os in +@@ -9747,6 +9748,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 : -@@ -9497,7 +9499,7 @@ return tgetent (); +@@ -9771,7 +9773,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 -@@ -717,7 +717,8 @@ if test x"$prefer_curses" = xyes; then +@@ -712,7 +712,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 -@@ -759,7 +760,8 @@ case $host_os in +@@ -754,7 +755,8 @@ case $host_os in esac # These are the libraries checked by Readline. diff --git a/gdb-gnat-dwarf-crash-3of3.patch b/gdb-gnat-dwarf-crash-3of3.patch index 52892e4..4197661 100644 --- a/gdb-gnat-dwarf-crash-3of3.patch +++ b/gdb-gnat-dwarf-crash-3of3.patch @@ -39,10 +39,10 @@ gdb/ * dwarf2read.c (process_die): Change gdb_assert to complaint. -diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -10657,6 +10657,13 @@ private: +diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c +--- a/gdb/dwarf2/read.c ++++ b/gdb/dwarf2/read.c +@@ -10162,6 +10162,13 @@ class process_die_scope static void process_die (struct die_info *die, struct dwarf2_cu *cu) { @@ -56,27 +56,10 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c process_die_scope scope (die, cu); switch (die->tag) -diff --git a/gdb/infrun.c b/gdb/infrun.c ---- a/gdb/infrun.c -+++ b/gdb/infrun.c -@@ -601,6 +601,13 @@ holding the child stopped. Try \"set detach-on-fork\" or \ - target_pid_to_str (process_ptid).c_str ()); - } - -+#ifdef NEED_DETACH_SIGSTOP -+ /* We should check PID_WAS_STOPPED and detach it stopped accordingly. -+ In this point of code it cannot be 1 as we would not get FORK -+ executed without CONTINUE first which resets PID_WAS_STOPPED. -+ We would have to first TARGET_STOP and WAITPID it as with running -+ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */ -+#endif - target_detach (parent_inf, 0); - } - diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c -@@ -189,6 +189,12 @@ struct linux_nat_target *linux_target; +@@ -190,6 +190,12 @@ struct linux_nat_target *linux_target; /* Does the current host support PTRACE_GETREGSET? */ enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN; @@ -89,17 +72,17 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c static unsigned int debug_linux_nat; static void show_debug_linux_nat (struct ui_file *file, int from_tty, -@@ -1030,6 +1036,9 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled) - if (debug_linux_nat) - fprintf_unfiltered (gdb_stdlog, - "LNPAW: Attaching to a stopped process\n"); +@@ -1044,6 +1050,9 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled) + if (linux_proc_pid_is_stopped (pid)) + { + linux_nat_debug_printf ("Attaching to a stopped process"); +#ifdef NEED_DETACH_SIGSTOP + pid_was_stopped = ptid.pid (); +#endif /* The process is definitely stopped. It is in a job control stop, unless the kernel predates the TASK_STOPPED / -@@ -1361,6 +1370,25 @@ get_detach_signal (struct lwp_info *lp) +@@ -1359,6 +1368,25 @@ get_detach_signal (struct lwp_info *lp) return gdb_signal_to_host (signo); } @@ -125,7 +108,7 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c return 0; } -@@ -1509,6 +1537,10 @@ linux_nat_target::detach (inferior *inf, int from_tty) +@@ -1502,6 +1530,10 @@ linux_nat_target::detach (inferior *inf, int from_tty) detach_one_lwp (main_lwp, &signo); detach_success (inf); @@ -136,7 +119,7 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c } } -@@ -1766,6 +1798,16 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo) +@@ -1744,6 +1776,16 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo) return; } @@ -153,7 +136,7 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c if (resume_many) iterate_over_lwps (ptid, [=] (struct lwp_info *info) { -@@ -3770,6 +3812,10 @@ linux_nat_target::mourn_inferior () +@@ -3617,6 +3659,10 @@ linux_nat_target::mourn_inferior () /* Let the arch-specific native code know this process is gone. */ linux_target->low_forget_process (pid); diff --git a/gdb-jit-reader-multilib.patch b/gdb-jit-reader-multilib.patch index ec41f13..4bce5fc 100644 --- a/gdb-jit-reader-multilib.patch +++ b/gdb-jit-reader-multilib.patch @@ -9,7 +9,7 @@ Subject: gdb-jit-reader-multilib.patch diff --git a/gdb/configure b/gdb/configure --- a/gdb/configure +++ b/gdb/configure -@@ -9694,10 +9694,12 @@ _ACEOF +@@ -9968,10 +9968,12 @@ _ACEOF @@ -28,7 +28,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 -@@ -808,10 +808,12 @@ AC_CHECK_SIZEOF(unsigned long long) +@@ -803,10 +803,12 @@ AC_CHECK_SIZEOF(unsigned long long) AC_CHECK_SIZEOF(unsigned long) AC_CHECK_SIZEOF(unsigned __int128) diff --git a/gdb-linux_perf-bundle.patch b/gdb-linux_perf-bundle.patch index db9e7c8..728f463 100644 --- a/gdb-linux_perf-bundle.patch +++ b/gdb-linux_perf-bundle.patch @@ -6,30 +6,6 @@ Subject: gdb-linux_perf-bundle.patch ;; [dts+el7] [x86*] Bundle linux_perf.h for libipt (RH BZ 1256513). ;;=fedora -diff --git a/gdb/configure b/gdb/configure ---- a/gdb/configure -+++ b/gdb/configure -@@ -11905,7 +11905,7 @@ else - - #include - #ifndef PERF_ATTR_SIZE_VER5 --# error -+// error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL - #endif - - _ACEOF -diff --git a/gdb/configure.ac b/gdb/configure.ac ---- a/gdb/configure.ac -+++ b/gdb/configure.ac -@@ -1414,7 +1414,7 @@ else - AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ - #include - #ifndef PERF_ATTR_SIZE_VER5 --# error -+// error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL - #endif - ]])], [perf_event=yes], [perf_event=no]) - if test "$perf_event" != yes; then diff --git a/gdb/gdb.c b/gdb/gdb.c --- a/gdb/gdb.c +++ b/gdb/gdb.c @@ -234,3 +210,15 @@ diff --git a/gdb/nat/linux-btrace.h b/gdb/nat/linux-btrace.h struct target_ops; #if HAVE_LINUX_PERF_EVENT_H +diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4 +--- a/gdbsupport/common.m4 ++++ b/gdbsupport/common.m4 +@@ -145,7 +145,7 @@ AC_DEFUN([GDB_AC_COMMON], [ + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ + #include + #ifndef PERF_ATTR_SIZE_VER5 +- # error ++ // error // PERF_ATTR_SIZE_VER5_BUNDLE is not available here - Fedora+RHEL + #endif + ]])], [perf_event=yes], [perf_event=no]) + if test "$perf_event" != yes; then diff --git a/gdb-moribund-utrace-workaround.patch b/gdb-moribund-utrace-workaround.patch index f2da872..869fc75 100644 --- a/gdb-moribund-utrace-workaround.patch +++ b/gdb-moribund-utrace-workaround.patch @@ -14,10 +14,10 @@ Bug in FSF GDB exploited by the ptrace-on-utrace interaction. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c -@@ -11904,6 +11904,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode) - traps we can no longer explain. */ - - old_loc->events_till_retirement = 3 * (thread_count () + 1); +@@ -11948,6 +11948,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode) + = 3 * (thread_count (proc_target) + 1); + else + old_loc->events_till_retirement = 1; + /* Red Hat Bug 590623. */ + old_loc->events_till_retirement *= 10; old_loc->owner = NULL; diff --git a/gdb-vla-intel-fix-print-char-array.patch b/gdb-vla-intel-fix-print-char-array.patch deleted file mode 100644 index ce2035c..0000000 --- a/gdb-vla-intel-fix-print-char-array.patch +++ /dev/null @@ -1,61 +0,0 @@ -From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Sergio Durigan Junior -Date: Thu, 7 Dec 2017 16:20:31 -0500 -Subject: gdb-vla-intel-fix-print-char-array.patch - -;; Revert upstream commit 469412dd9ccc4de5874fd3299b105833f36b34cd - -Revert commit (only the part touching gdb/f-valprint.c): - - commit 469412dd9ccc4de5874fd3299b105833f36b34cd - Author: Christoph Weinmann - Date: Fri Sep 8 15:11:47 2017 +0200 - - Remove C/C++ relevant code in Fortran specific file. - - Remove code relevant for printing C/C++ Integer values in a - Fortran specific file to unify printing of Fortran values. - This does not change the output. - -And adjust its testcase. - -diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c ---- a/gdb/f-valprint.c -+++ b/gdb/f-valprint.c -@@ -319,8 +319,22 @@ f_val_print (struct type *type, int embedded_offset, - original_value, &opts, 0, stream); - } - else -- val_print_scalar_formatted (type, embedded_offset, -- original_value, options, 0, stream); -+ { -+ val_print_scalar_formatted (type, embedded_offset, -+ original_value, options, 0, stream); -+ /* C and C++ has no single byte int type, char is used instead. -+ Since we don't know whether the value is really intended to -+ be used as an integer or a character, print the character -+ equivalent as well. */ -+ if (TYPE_LENGTH (type) == 1) -+ { -+ LONGEST c; -+ -+ fputs_filtered (" ", stream); -+ c = unpack_long (type, valaddr + embedded_offset); -+ LA_PRINT_CHAR ((unsigned char) c, type, stream); -+ } -+ } - break; - - case TYPE_CODE_STRUCT: -diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp ---- a/gdb/testsuite/gdb.fortran/printing-types.exp -+++ b/gdb/testsuite/gdb.fortran/printing-types.exp -@@ -29,7 +29,7 @@ if {![runto MAIN__]} then { - gdb_breakpoint [gdb_get_line_number "write"] - gdb_continue_to_breakpoint "write" - --gdb_test "print oneByte" " = 1" -+gdb_test "print oneByte" " = 1 \'\\\\001\'" - gdb_test "print twobytes" " = 2" - gdb_test "print chvalue" " = \'a\'" - gdb_test "print logvalue" " = \.TRUE\." diff --git a/gdb-vla-intel-fortran-strides.patch b/gdb-vla-intel-fortran-strides.patch deleted file mode 100644 index 4f468eb..0000000 --- a/gdb-vla-intel-fortran-strides.patch +++ /dev/null @@ -1,1787 +0,0 @@ -From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Fedora GDB patches -Date: Fri, 27 Oct 2017 21:07:50 +0200 -Subject: gdb-vla-intel-fortran-strides.patch - -;; VLA (Fortran dynamic arrays) from Intel + archer-jankratochvil-vla tests. -;;=push - -git diff --stat -p gdb/master...gdb/users/bheckel/fortran-strides -dbfd7140bf4c0500d1f5d192be781f83f78f7922 - - gdb/dwarf2loc.c | 46 ++- - gdb/dwarf2loc.h | 6 + - gdb/dwarf2read.c | 13 +- - gdb/eval.c | 391 +++++++++++++++++++++----- - gdb/expprint.c | 20 +- - gdb/expression.h | 18 +- - gdb/f-exp.y | 42 ++- - gdb/f-valprint.c | 8 +- - gdb/gdbtypes.c | 34 ++- - gdb/gdbtypes.h | 18 +- - gdb/parse.c | 24 +- - gdb/rust-exp.y | 12 +- - gdb/rust-lang.c | 17 +- - gdb/testsuite/gdb.fortran/static-arrays.exp | 421 ++++++++++++++++++++++++++++ - gdb/testsuite/gdb.fortran/static-arrays.f90 | 55 ++++ - gdb/testsuite/gdb.fortran/vla-ptype.exp | 4 + - gdb/testsuite/gdb.fortran/vla-sizeof.exp | 4 + - gdb/testsuite/gdb.fortran/vla-stride.exp | 44 +++ - gdb/testsuite/gdb.fortran/vla-stride.f90 | 29 ++ - gdb/testsuite/gdb.fortran/vla.f90 | 10 + - gdb/valarith.c | 10 +- - gdb/valops.c | 197 +++++++++++-- - gdb/value.h | 2 + - 23 files changed, 1242 insertions(+), 183 deletions(-) - -diff --git a/gdb/eval.c b/gdb/eval.c ---- a/gdb/eval.c -+++ b/gdb/eval.c -@@ -372,29 +372,324 @@ init_array_element (struct value *array, struct value *element, - return index; - } - -+/* Evaluates any operation on Fortran arrays or strings with at least -+ one user provided parameter. Expects the input ARRAY to be either -+ an array, or a string. Evaluates EXP by incrementing POS, and -+ writes the content from the elt stack into a local struct. NARGS -+ specifies number of literal or range arguments the user provided. -+ NARGS must be the same number as ARRAY has dimensions. */ -+ - static struct value * --value_f90_subarray (struct value *array, -- struct expression *exp, int *pos, enum noside noside) -+value_f90_subarray (struct value *array, struct expression *exp, -+ int *pos, int nargs, enum noside noside) - { -- int pc = (*pos) + 1; -- LONGEST low_bound, high_bound; -- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array))); -- enum range_type range_type -- = (enum range_type) longest_to_int (exp->elts[pc].longconst); -- -- *pos += 3; -- -- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) -- low_bound = TYPE_LOW_BOUND (range); -- else -- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); -+ int i, dim_count = 0; -+ struct value *new_array = array; -+ struct type *array_type = check_typedef (value_type (new_array)); -+ struct type *elt_type; -+ -+ typedef struct -+ { -+ enum range_type f90_range_type; -+ LONGEST low, high, stride; -+ } subscript_range; -+ -+ typedef enum subscript_kind -+ { -+ SUBSCRIPT_RANGE, /* e.g. "(lowbound:highbound)" */ -+ SUBSCRIPT_INDEX /* e.g. "(literal)" */ -+ } kind; -+ -+ /* Local struct to hold user data for Fortran subarray dimensions. */ -+ struct subscript_store -+ { -+ /* For every dimension, we are either working on a range or an index -+ expression, so we store this info separately for later. */ -+ enum subscript_kind kind; -+ -+ /* We also store either the lower and upper bound info, or the index -+ number. Before evaluation of the input values, we do not know if we are -+ actually working on a range of ranges, or an index in a range. So as a -+ first step we store all input in a union. The array calculation itself -+ deals with this later on. */ -+ union element_range -+ { -+ subscript_range range; -+ LONGEST number; -+ } U; -+ } *subscript_array; -+ -+ /* Check if the number of arguments provided by the user matches -+ the number of dimension of the array. A string has only one -+ dimension. */ -+ if (nargs != calc_f77_array_dims (value_type (new_array))) -+ error (_("Wrong number of subscripts")); -+ -+ subscript_array = (struct subscript_store*) alloca (sizeof (*subscript_array) * nargs); -+ -+ /* Parse the user input into the SUBSCRIPT_ARRAY to store it. We need -+ to evaluate it first, as the input is from left-to-right. The -+ array is stored from right-to-left. So we have to use the user -+ input in reverse order. Later on, we need the input information to -+ re-calculate the output array. For multi-dimensional arrays, we -+ can be dealing with any possible combination of ranges and indices -+ for every dimension. */ -+ for (i = 0; i < nargs; i++) -+ { -+ struct subscript_store *index = &subscript_array[i]; -+ -+ /* The user input is a range, with or without lower and upper bound. -+ E.g.: "p arry(2:5)", "p arry( :5)", "p arry( : )", etc. */ -+ if (exp->elts[*pos].opcode == OP_RANGE) -+ { -+ int pc = (*pos) + 1; -+ subscript_range *range; -+ -+ index->kind = SUBSCRIPT_RANGE; -+ range = &index->U.range; -+ -+ *pos += 3; -+ range->f90_range_type = (enum range_type) exp->elts[pc].longconst; -+ -+ /* If a lower bound was provided by the user, the bit has been -+ set and we can assign the value from the elt stack. Same for -+ upper bound. */ -+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND) -+ == SUBARRAY_LOW_BOUND) -+ range->low = value_as_long (evaluate_subexp (NULL_TYPE, exp, -+ pos, noside)); -+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) -+ == SUBARRAY_HIGH_BOUND) -+ range->high = value_as_long (evaluate_subexp (NULL_TYPE, exp, -+ pos, noside)); -+ -+ /* Assign the user's stride value if provided. */ -+ if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE) -+ range->stride = value_as_long (evaluate_subexp (NULL_TYPE, exp, -+ pos, noside)); -+ -+ /* Assign the default stride value '1'. */ -+ else -+ range->stride = 1; - -- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) -- high_bound = TYPE_HIGH_BOUND (range); -- else -- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); -+ /* Check the provided stride value is illegal, aka '0'. */ -+ if (range->stride == 0) -+ error (_("Stride must not be 0")); -+ } -+ /* User input is an index. E.g.: "p arry(5)". */ -+ else -+ { -+ struct value *val; -+ -+ index->kind = SUBSCRIPT_INDEX; -+ -+ /* Evaluate each subscript; it must be a legal integer in F77. This -+ ensures the validity of the provided index. */ -+ val = evaluate_subexp_with_coercion (exp, pos, noside); -+ index->U.number = value_as_long (val); -+ } -+ -+ } -+ -+ /* Traverse the array from right to left and set the high and low bounds -+ for later use. */ -+ for (i = nargs - 1; i >= 0; i--) -+ { -+ struct subscript_store *index = &subscript_array[i]; -+ struct type *index_type = TYPE_INDEX_TYPE (array_type); -+ -+ switch (index->kind) -+ { -+ case SUBSCRIPT_RANGE: -+ { -+ -+ /* When we hit the first range specified by the user, we must -+ treat any subsequent user entry as a range. We simply -+ increment DIM_COUNT which tells us how many times we are -+ calling VALUE_SLICE_1. */ -+ subscript_range *range = &index->U.range; -+ -+ /* If no lower bound was provided by the user, we take the -+ default boundary. Same for the high bound. */ -+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND) == 0) -+ range->low = TYPE_LOW_BOUND (index_type); -+ -+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) == 0) -+ range->high = TYPE_HIGH_BOUND (index_type); -+ -+ /* Both user provided low and high bound have to be inside the -+ array bounds. Throw an error if not. */ -+ if (range->low < TYPE_LOW_BOUND (index_type) -+ || range->low > TYPE_HIGH_BOUND (index_type) -+ || range->high < TYPE_LOW_BOUND (index_type) -+ || range->high > TYPE_HIGH_BOUND (index_type)) -+ error (_("provided bound(s) outside array bound(s)")); -+ -+ /* For a negative stride the lower boundary must be larger than the -+ upper boundary. -+ For a positive stride the lower boundary must be smaller than the -+ upper boundary. */ -+ if ((range->stride < 0 && range->low < range->high) -+ || (range->stride > 0 && range->low > range->high)) -+ error (_("Wrong value provided for stride and boundaries")); -+ -+ } -+ break; -+ -+ case SUBSCRIPT_INDEX: -+ break; -+ -+ } -+ -+ array_type = TYPE_TARGET_TYPE (array_type); -+ } -+ -+ /* Reset ARRAY_TYPE before slicing.*/ -+ array_type = check_typedef (value_type (new_array)); -+ -+ /* Traverse the array from right to left and evaluate each corresponding -+ user input. VALUE_SUBSCRIPT is called for every index, until a range -+ expression is evaluated. After a range expression has been evaluated, -+ every subsequent expression is also treated as a range. */ -+ for (i = nargs - 1; i >= 0; i--) -+ { -+ struct subscript_store *index = &subscript_array[i]; -+ struct type *index_type = TYPE_INDEX_TYPE (array_type); -+ -+ switch (index->kind) -+ { -+ case SUBSCRIPT_RANGE: -+ { -+ -+ /* When we hit the first range specified by the user, we must -+ treat any subsequent user entry as a range. We simply -+ increment DIM_COUNT which tells us how many times we are -+ calling VALUE_SLICE_1. */ -+ subscript_range *range = &index->U.range; -+ -+ /* DIM_COUNT counts every user argument that is treated as a range. -+ This is necessary for expressions like 'print array(7, 8:9). -+ Here the first argument is a literal, but must be treated as a -+ range argument to allow the correct output representation. */ -+ dim_count++; -+ -+ new_array -+ = value_slice_1 (new_array, range->low, -+ range->high - range->low + 1, -+ range->stride, dim_count); -+ } -+ break; -+ -+ case SUBSCRIPT_INDEX: -+ { -+ /* DIM_COUNT only stays '0' when no range argument was processed -+ before, starting from the last dimension. This way we can -+ reduce the number of dimensions from the result array. -+ However, if a range has been processed before an index, we -+ treat the index like a range with equal low- and high bounds -+ to get the value offset right. */ -+ if (dim_count == 0) -+ new_array -+ = value_subscripted_rvalue (new_array, index->U.number, -+ f77_get_lowerbound (value_type -+ (new_array))); -+ else -+ { -+ dim_count++; -+ -+ /* We might end up here, because we have to treat the provided -+ index like a range. But now VALUE_SUBSCRIPTED_RVALUE -+ cannot do the range checks for us. So we have to make sure -+ ourselves that the user provided index is inside the -+ array bounds. Throw an error if not. */ -+ if (index->U.number < TYPE_LOW_BOUND (index_type) -+ && index->U.number > TYPE_HIGH_BOUND (index_type)) -+ error (_("provided bound(s) outside array bound(s)")); -+ -+ if (index->U.number > TYPE_LOW_BOUND (index_type) -+ && index->U.number > TYPE_HIGH_BOUND (index_type)) -+ error (_("provided bound(s) outside array bound(s)")); -+ -+ new_array = value_slice_1 (new_array, -+ index->U.number, -+ 1, /* COUNT is '1' element */ -+ 1, /* STRIDE set to '1' */ -+ dim_count); -+ } -+ -+ } -+ break; -+ } -+ array_type = TYPE_TARGET_TYPE (array_type); -+ } -+ -+ /* With DIM_COUNT > 1 we currently have a one dimensional array, but expect -+ an array of arrays, depending on how many ranges have been provided by -+ the user. So we need to rebuild the array dimensions for printing it -+ correctly. -+ Starting from right to left in the user input, after we hit the first -+ range argument every subsequent argument is also treated as a range. -+ E.g.: -+ "p ary(3, 7, 2:15)" in Fortran has only 1 dimension, but we calculated 3 -+ ranges. -+ "p ary(3, 7:12, 4)" in Fortran has only 1 dimension, but we calculated 2 -+ ranges. -+ "p ary(2:4, 5, 7)" in Fortran has only 1 dimension, and we calculated 1 -+ range. */ -+ if (dim_count > 1) -+ { -+ struct value *v = NULL; -+ -+ elt_type = TYPE_TARGET_TYPE (value_type (new_array)); - -- return value_slice (array, low_bound, high_bound - low_bound + 1); -+ /* Every SUBSCRIPT_RANGE in the user input signifies an actual range in -+ the output array. So we traverse the SUBSCRIPT_ARRAY again, looking -+ for a range entry. When we find one, we use the range info to create -+ an additional range_type to set the correct bounds and dimensions for -+ the output array. In addition, we may have a stride value that is not -+ '1', forcing us to adjust the number of elements in a range, according -+ to the stride value. */ -+ for (i = 0; i < nargs; i++) -+ { -+ struct subscript_store *index = &subscript_array[i]; -+ -+ if (index->kind == SUBSCRIPT_RANGE) -+ { -+ struct type *range_type, *interim_array_type; -+ -+ int new_length; -+ -+ /* The length of a sub-dimension with all elements between the -+ bounds plus the start element itself. It may be modified by -+ a user provided stride value. */ -+ new_length = index->U.range.high - index->U.range.low; -+ -+ new_length /= index->U.range.stride; -+ -+ range_type -+ = create_static_range_type (NULL, -+ elt_type, -+ index->U.range.low, -+ index->U.range.low + new_length); -+ -+ interim_array_type = create_array_type (NULL, -+ elt_type, -+ range_type); -+ -+ TYPE_CODE (interim_array_type) -+ = TYPE_CODE (value_type (new_array)); -+ -+ v = allocate_value (interim_array_type); -+ -+ elt_type = value_type (v); -+ } -+ -+ } -+ value_contents_copy (v, 0, new_array, 0, TYPE_LENGTH (elt_type)); -+ return v; -+ } -+ -+ return new_array; - } - - -@@ -1235,19 +1530,6 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, - return eval_call (exp, noside, nargs, argvec, var_func_name, expect_type); - } - --/* Helper for skipping all the arguments in an undetermined argument list. -- This function was designed for use in the OP_F77_UNDETERMINED_ARGLIST -- case of evaluate_subexp_standard as multiple, but not all, code paths -- require a generic skip. */ -- --static void --skip_undetermined_arglist (int nargs, struct expression *exp, int *pos, -- enum noside noside) --{ -- for (int i = 0; i < nargs; ++i) -- evaluate_subexp (NULL_TYPE, exp, pos, noside); --} -- - struct value * - evaluate_subexp_standard (struct type *expect_type, - struct expression *exp, int *pos, -@@ -1942,33 +2224,8 @@ evaluate_subexp_standard (struct type *expect_type, - switch (code) - { - case TYPE_CODE_ARRAY: -- if (exp->elts[*pos].opcode == OP_RANGE) -- return value_f90_subarray (arg1, exp, pos, noside); -- else -- { -- if (noside == EVAL_SKIP) -- { -- skip_undetermined_arglist (nargs, exp, pos, noside); -- /* Return the dummy value with the correct type. */ -- return arg1; -- } -- goto multi_f77_subscript; -- } -- - case TYPE_CODE_STRING: -- if (exp->elts[*pos].opcode == OP_RANGE) -- return value_f90_subarray (arg1, exp, pos, noside); -- else -- { -- if (noside == EVAL_SKIP) -- { -- skip_undetermined_arglist (nargs, exp, pos, noside); -- /* Return the dummy value with the correct type. */ -- return arg1; -- } -- arg2 = evaluate_subexp_with_coercion (exp, pos, noside); -- return value_subscript (arg1, value_as_long (arg2)); -- } -+ return value_f90_subarray (arg1, exp, pos, nargs, noside); - - case TYPE_CODE_PTR: - case TYPE_CODE_FUNC: -@@ -2388,49 +2645,6 @@ evaluate_subexp_standard (struct type *expect_type, - } - return (arg1); - -- multi_f77_subscript: -- { -- LONGEST subscript_array[MAX_FORTRAN_DIMS]; -- int ndimensions = 1, i; -- struct value *array = arg1; -- -- if (nargs > MAX_FORTRAN_DIMS) -- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS); -- -- ndimensions = calc_f77_array_dims (type); -- -- if (nargs != ndimensions) -- error (_("Wrong number of subscripts")); -- -- gdb_assert (nargs > 0); -- -- /* Now that we know we have a legal array subscript expression -- let us actually find out where this element exists in the array. */ -- -- /* Take array indices left to right. */ -- for (i = 0; i < nargs; i++) -- { -- /* Evaluate each subscript; it must be a legal integer in F77. */ -- arg2 = evaluate_subexp_with_coercion (exp, pos, noside); -- -- /* Fill in the subscript array. */ -- -- subscript_array[i] = value_as_long (arg2); -- } -- -- /* Internal type of array is arranged right to left. */ -- for (i = nargs; i > 0; i--) -- { -- struct type *array_type = check_typedef (value_type (array)); -- LONGEST index = subscript_array[i - 1]; -- -- array = value_subscripted_rvalue (array, index, -- f77_get_lowerbound (array_type)); -- } -- -- return array; -- } -- - case BINOP_LOGICAL_AND: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) -@@ -3350,6 +3564,9 @@ calc_f77_array_dims (struct type *array_type) - int ndimen = 1; - struct type *tmp_type; - -+ if (TYPE_CODE (array_type) == TYPE_CODE_STRING) -+ return 1; -+ - if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY)) - error (_("Can't get dimensions for a non-array type")); - -diff --git a/gdb/expprint.c b/gdb/expprint.c ---- a/gdb/expprint.c -+++ b/gdb/expprint.c -@@ -580,17 +580,14 @@ print_subexp_standard (struct expression *exp, int *pos, - longest_to_int (exp->elts[pc + 1].longconst); - *pos += 2; - -- if (range_type == NONE_BOUND_DEFAULT_EXCLUSIVE -- || range_type == LOW_BOUND_DEFAULT_EXCLUSIVE) -+ if ((range_type & SUBARRAY_HIGH_BOUND_EXCLUSIVE) -+ == SUBARRAY_HIGH_BOUND_EXCLUSIVE) - fputs_filtered ("EXCLUSIVE_", stream); - fputs_filtered ("RANGE(", stream); -- if (range_type == HIGH_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE) -+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND) - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - fputs_filtered ("..", stream); -- if (range_type == LOW_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT) -+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND) - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - fputs_filtered (")", stream); - return; -@@ -1107,22 +1104,24 @@ dump_subexp_body_standard (struct expression *exp, - - switch (range_type) - { -- case BOTH_BOUND_DEFAULT: -+ case SUBARRAY_NONE_BOUND: - fputs_filtered ("Range '..'", stream); - break; -- case LOW_BOUND_DEFAULT: -+ case SUBARRAY_HIGH_BOUND: - fputs_filtered ("Range '..EXP'", stream); - break; -- case LOW_BOUND_DEFAULT_EXCLUSIVE: -- fputs_filtered ("ExclusiveRange '..EXP'", stream); -- break; -- case HIGH_BOUND_DEFAULT: -+ case SUBARRAY_LOW_BOUND: - fputs_filtered ("Range 'EXP..'", stream); - break; -- case NONE_BOUND_DEFAULT: -+ case (SUBARRAY_LOW_BOUND -+ | SUBARRAY_HIGH_BOUND -+ | SUBARRAY_HIGH_BOUND_EXCLUSIVE): -+ fputs_filtered ("ExclusiveRange '..EXP'", stream); -+ break; -+ case (SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND): - fputs_filtered ("Range 'EXP..EXP'", stream); - break; -- case NONE_BOUND_DEFAULT_EXCLUSIVE: -+ case (SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE): - fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream); - break; - default: -@@ -1130,11 +1129,9 @@ dump_subexp_body_standard (struct expression *exp, - break; - } - -- if (range_type == HIGH_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT) -+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND) - elt = dump_subexp (exp, stream, elt); -- if (range_type == LOW_BOUND_DEFAULT -- || range_type == NONE_BOUND_DEFAULT) -+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND) - elt = dump_subexp (exp, stream, elt); - } - break; -diff --git a/gdb/expression.h b/gdb/expression.h ---- a/gdb/expression.h -+++ b/gdb/expression.h -@@ -167,28 +167,27 @@ extern void dump_raw_expression (struct expression *, - struct ui_file *, const char *); - extern void dump_prefix_expression (struct expression *, struct ui_file *); - --/* In an OP_RANGE expression, either bound could be empty, indicating -- that its value is by default that of the corresponding bound of the -- array or string. Also, the upper end of the range can be exclusive -- or inclusive. So we have six sorts of subrange. This enumeration -- type is to identify this. */ -+/* In an OP_RANGE expression, either bound can be provided by the -+ user, or not. In addition to this, the user can also specify a -+ stride value to indicated only certain elements of the array. -+ Also, the upper end of the range can be exclusive or inclusive. -+ This enumeration type is to identify this. */ - - enum range_type --{ -- /* Neither the low nor the high bound was given -- so this refers to -- the entire available range. */ -- BOTH_BOUND_DEFAULT, -- /* The low bound was not given and the high bound is inclusive. */ -- LOW_BOUND_DEFAULT, -- /* The high bound was not given and the low bound in inclusive. */ -- HIGH_BOUND_DEFAULT, -- /* Both bounds were given and both are inclusive. */ -- NONE_BOUND_DEFAULT, -- /* The low bound was not given and the high bound is exclusive. */ -- NONE_BOUND_DEFAULT_EXCLUSIVE, -- /* Both bounds were given. The low bound is inclusive and the high -- bound is exclusive. */ -- LOW_BOUND_DEFAULT_EXCLUSIVE, --}; -+ { -+ SUBARRAY_NONE_BOUND = 0x0, /* "( : )" */ -+ SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" */ -+ SUBARRAY_HIGH_BOUND = 0x2, /* "(:high)" */ -+ SUBARRAY_STRIDE = 0x4, /* "(::stride)" */ -+ /* The low bound was not given and the high bound is exclusive. -+ In this case we always use (SUBARRAY_HIGH_BOUND | -+ SUBARRAY_HIGH_BOUND_EXCLUSIVE). */ -+ SUBARRAY_HIGH_BOUND_EXCLUSIVE = 0x8, -+ /* Both bounds were given. The low bound is inclusive and the high -+ bound is exclusive. In this case, we use (SUBARRAY_LOW_BOUND | -+ SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE). */ -+ // SUBARRAY_LOW_BOUND_EXCLUSIVE = (SUBARRAY_LOW_BOUND -+ // | SUBARRAY_HIGH_BOUND_EXCLUSIVE), -+ }; - - #endif /* !defined (EXPRESSION_H) */ -diff --git a/gdb/f-exp.y b/gdb/f-exp.y ---- a/gdb/f-exp.y -+++ b/gdb/f-exp.y -@@ -282,31 +282,63 @@ arglist : subrange - - arglist : arglist ',' exp %prec ABOVE_COMMA - { pstate->arglist_len++; } -+ | arglist ',' subrange %prec ABOVE_COMMA -+ { pstate->arglist_len++; } - ; - - /* There are four sorts of subrange types in F90. */ - - subrange: exp ':' exp %prec ABOVE_COMMA -- { write_exp_elt_opcode (pstate, OP_RANGE); -- write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT); -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, -+ SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND); - write_exp_elt_opcode (pstate, OP_RANGE); } - ; - - subrange: exp ':' %prec ABOVE_COMMA - { write_exp_elt_opcode (pstate, OP_RANGE); -- write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT); -+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND); - write_exp_elt_opcode (pstate, OP_RANGE); } - ; - - subrange: ':' exp %prec ABOVE_COMMA - { write_exp_elt_opcode (pstate, OP_RANGE); -- write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT); -+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND); - write_exp_elt_opcode (pstate, OP_RANGE); } - ; - - subrange: ':' %prec ABOVE_COMMA - { write_exp_elt_opcode (pstate, OP_RANGE); -- write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT); -+ write_exp_elt_longcst (pstate, SUBARRAY_NONE_BOUND); -+ write_exp_elt_opcode (pstate, OP_RANGE); } -+ ; -+ -+/* Each subrange type can have a stride argument. */ -+subrange: exp ':' exp ':' exp %prec ABOVE_COMMA -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND -+ | SUBARRAY_HIGH_BOUND -+ | SUBARRAY_STRIDE); -+ write_exp_elt_opcode (pstate, OP_RANGE); } -+ ; -+ -+subrange: exp ':' ':' exp %prec ABOVE_COMMA -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND -+ | SUBARRAY_STRIDE); -+ write_exp_elt_opcode (pstate, OP_RANGE); } -+ ; -+ -+subrange: ':' exp ':' exp %prec ABOVE_COMMA -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND -+ | SUBARRAY_STRIDE); -+ write_exp_elt_opcode (pstate, OP_RANGE); } -+ ; -+ -+subrange: ':' ':' exp %prec ABOVE_COMMA -+ { write_exp_elt_opcode (pstate, OP_RANGE); -+ write_exp_elt_longcst (pstate, SUBARRAY_STRIDE); - write_exp_elt_opcode (pstate, OP_RANGE); } - ; - -diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c ---- a/gdb/f-valprint.c -+++ b/gdb/f-valprint.c -@@ -129,6 +129,11 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type, - byte_stride = dim_size; - size_t offs = 0; - -+ if (byte_stride) -+ dim_size = byte_stride; -+ else -+ dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type)); -+ - for (i = lowerbound; - (i < upperbound + 1 && (*elts) < options->print_max); - i++) -diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c ---- a/gdb/gdbtypes.c -+++ b/gdb/gdbtypes.c -@@ -936,7 +936,7 @@ create_range_type (struct type *result_type, struct type *index_type, - TYPE_RANGE_DATA (result_type)->high = *high_bound; - TYPE_RANGE_DATA (result_type)->bias = bias; - -- /* Initialize the stride to be a constant, the value will already be zero -+ /* bias the stride to be a constant, the value will already be zero - thanks to the use of TYPE_ZALLOC above. */ - TYPE_RANGE_DATA (result_type)->stride.kind = PROP_CONST; - -@@ -1001,7 +1001,8 @@ create_static_range_type (struct type *result_type, struct type *index_type, - high.kind = PROP_CONST; - high.data.const_val = high_bound; - -- result_type = create_range_type (result_type, index_type, &low, &high, 0); -+ result_type = create_range_type (result_type, index_type, -+ &low, &high, 0); - - return result_type; - } -@@ -1236,6 +1237,7 @@ create_array_type_with_stride (struct type *result_type, - if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) - low_bound = high_bound = 0; - element_type = check_typedef (element_type); -+ - /* Be careful when setting the array length. Ada arrays can be - empty arrays with the high_bound being smaller than the low_bound. - In such cases, the array length should be zero. */ -diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h ---- a/gdb/gdbtypes.h -+++ b/gdb/gdbtypes.h -@@ -803,7 +803,6 @@ struct main_type - /* * Union member used for range types. */ - - struct range_bounds *bounds; -- - } flds_bnds; - - /* * Slot to point to additional language-specific fields of this -@@ -1365,6 +1364,15 @@ extern bool set_type_align (struct type *, ULONGEST); - #define TYPE_BIT_STRIDE(range_type) \ - (TYPE_RANGE_DATA(range_type)->stride.data.const_val \ - * (TYPE_RANGE_DATA(range_type)->flag_is_byte_stride ? 8 : 1)) -+#define TYPE_BYTE_STRIDE(range_type) \ -+ TYPE_RANGE_DATA(range_type)->stride.data.const_val -+#define TYPE_BYTE_STRIDE_BLOCK(range_type) \ -+ TYPE_RANGE_DATA(range_type)->stride.data.locexpr -+#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \ -+ TYPE_RANGE_DATA(range_type)->stride.data.loclist -+#define TYPE_BYTE_STRIDE_KIND(range_type) \ -+ TYPE_RANGE_DATA(range_type)->stride.kind -+ - - /* Property accessors for the type data location. */ - #define TYPE_DATA_LOCATION(thistype) \ -@@ -1400,6 +1408,9 @@ extern bool set_type_align (struct type *, ULONGEST); - TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype)) - #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \ - TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype)) -+#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \ -+ (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0) -+ - - #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \ - (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype)))) -diff --git a/gdb/parse.c b/gdb/parse.c ---- a/gdb/parse.c -+++ b/gdb/parse.c -@@ -919,24 +919,20 @@ operator_length_standard (const struct expression *expr, int endpos, - - case OP_RANGE: - oplen = 3; -+ args = 0; - range_type = (enum range_type) - longest_to_int (expr->elts[endpos - 2].longconst); - -- switch (range_type) -- { -- case LOW_BOUND_DEFAULT: -- case LOW_BOUND_DEFAULT_EXCLUSIVE: -- case HIGH_BOUND_DEFAULT: -- args = 1; -- break; -- case BOTH_BOUND_DEFAULT: -- args = 0; -- break; -- case NONE_BOUND_DEFAULT: -- case NONE_BOUND_DEFAULT_EXCLUSIVE: -- args = 2; -- break; -- } -+ /* Increment the argument counter for each argument -+ provided by the user. */ -+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND) -+ args++; -+ -+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND) -+ args++; -+ -+ if ((range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE) -+ args++; - - break; - -diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y ---- a/gdb/rust-exp.y -+++ b/gdb/rust-exp.y -@@ -2492,24 +2492,28 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation, - - case OP_RANGE: - { -- enum range_type kind = BOTH_BOUND_DEFAULT; -+ enum range_type kind = SUBARRAY_NONE_BOUND; - - if (operation->left.op != NULL) - { - convert_ast_to_expression (operation->left.op, top); -- kind = HIGH_BOUND_DEFAULT; -+ kind = SUBARRAY_LOW_BOUND; - } - if (operation->right.op != NULL) - { - convert_ast_to_expression (operation->right.op, top); -- if (kind == BOTH_BOUND_DEFAULT) -- kind = (operation->inclusive -- ? LOW_BOUND_DEFAULT : LOW_BOUND_DEFAULT_EXCLUSIVE); -+ if (kind == SUBARRAY_NONE_BOUND) -+ { -+ kind = (range_type) SUBARRAY_HIGH_BOUND; -+ if (!operation->inclusive) -+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE); -+ } - else - { -- gdb_assert (kind == HIGH_BOUND_DEFAULT); -- kind = (operation->inclusive -- ? NONE_BOUND_DEFAULT : NONE_BOUND_DEFAULT_EXCLUSIVE); -+ gdb_assert (kind == SUBARRAY_LOW_BOUND); -+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND); -+ if (!operation->inclusive) -+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE); - } - } - else -diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c ---- a/gdb/rust-lang.c -+++ b/gdb/rust-lang.c -@@ -1224,13 +1224,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside) - kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst); - *pos += 3; - -- if (kind == HIGH_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT -- || kind == NONE_BOUND_DEFAULT_EXCLUSIVE) -+ if ((kind & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND) - low = evaluate_subexp (NULL_TYPE, exp, pos, noside); -- if (kind == LOW_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT_EXCLUSIVE -- || kind == NONE_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT_EXCLUSIVE) -+ if ((kind & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND) - high = evaluate_subexp (NULL_TYPE, exp, pos, noside); -- bool inclusive = (kind == NONE_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT); -+ bool inclusive = (!((kind & SUBARRAY_HIGH_BOUND_EXCLUSIVE) == SUBARRAY_HIGH_BOUND_EXCLUSIVE)); - - if (noside == EVAL_SKIP) - return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1); -@@ -1319,7 +1317,7 @@ rust_compute_range (struct type *type, struct value *range, - - *low = 0; - *high = 0; -- *kind = BOTH_BOUND_DEFAULT; -+ *kind = SUBARRAY_NONE_BOUND; - - if (TYPE_NFIELDS (type) == 0) - return; -@@ -1327,15 +1325,14 @@ rust_compute_range (struct type *type, struct value *range, - i = 0; - if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0) - { -- *kind = HIGH_BOUND_DEFAULT; -+ *kind = SUBARRAY_LOW_BOUND; - *low = value_as_long (value_field (range, 0)); - ++i; - } - if (TYPE_NFIELDS (type) > i - && strcmp (TYPE_FIELD_NAME (type, i), "end") == 0) - { -- *kind = (*kind == BOTH_BOUND_DEFAULT -- ? LOW_BOUND_DEFAULT : NONE_BOUND_DEFAULT); -+ *kind = (range_type) (*kind | SUBARRAY_HIGH_BOUND); - *high = value_as_long (value_field (range, i)); - - if (rust_inclusive_range_type_p (type)) -@@ -1353,7 +1350,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside, - struct type *rhstype; - LONGEST low, high_bound; - /* Initialized to appease the compiler. */ -- enum range_type kind = BOTH_BOUND_DEFAULT; -+ enum range_type kind = SUBARRAY_NONE_BOUND; - LONGEST high = 0; - int want_slice = 0; - -@@ -1451,7 +1448,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside, - error (_("Cannot subscript non-array type")); - - if (want_slice -- && (kind == BOTH_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT)) -+ && ((kind & SUBARRAY_LOW_BOUND) != SUBARRAY_LOW_BOUND)) - low = low_bound; - if (low < 0) - error (_("Index less than zero")); -@@ -1469,7 +1466,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside, - CORE_ADDR addr; - struct value *addrval, *tem; - -- if (kind == BOTH_BOUND_DEFAULT || kind == HIGH_BOUND_DEFAULT) -+ if ((kind & SUBARRAY_HIGH_BOUND) != SUBARRAY_HIGH_BOUND) - high = high_bound; - if (high < 0) - error (_("High index less than zero")); -diff --git a/gdb/testsuite/gdb.fortran/static-arrays.exp b/gdb/testsuite/gdb.fortran/static-arrays.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/static-arrays.exp -@@ -0,0 +1,421 @@ -+# Copyright 2015 Free Software Foundation, Inc. -+# -+# Contributed by Intel Corp. -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+standard_testfile static-arrays.f90 -+ -+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] } { -+ return -1 -+} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_breakpoint [gdb_get_line_number "BP1"] -+gdb_continue_to_breakpoint "BP1" ".*BP1.*" -+ -+# Tests subarrays of one dimensional arrays with subrange variations -+gdb_test "print ar1" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \ -+ "print ar1." -+gdb_test "print ar1\(4:7\)" "\\$\[0-9\]+ = \\(4, 5, 6, 7\\)" \ -+ "print ar1\(4:7\)" -+gdb_test "print ar1\(8:\)" "\\$\[0-9\]+ = \\(8, 9\\).*" \ -+ "print ar1\(8:\)" -+gdb_test "print ar1\(:3\)" "\\$\[0-9\]+ = \\(1, 2, 3\\).*" \ -+ "print ar1\(:3\)" -+gdb_test "print ar1\(:\)" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \ -+ "print ar1\(:\)" -+ -+# Check assignment -+gdb_test_no_output "set \$my_ary = ar1\(3:8\)" -+gdb_test "print \$my_ary" \ -+ "\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \ -+ "Assignment of subarray to variable" -+gdb_test_no_output "set ar1\(5\) = 42" -+ gdb_test "print ar1\(3:8\)" \ -+ "\\$\[0-9\]+ = \\(3, 4, 42, 6, 7, 8\\)" \ -+ "print ar1\(3:8\) after assignment" -+gdb_test "print \$my_ary" \ -+ "\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \ -+ "Assignment of subarray to variable after original array changed" -+ -+# Test for subarrays of one dimensional arrays with literals -+ gdb_test "print ar1\(3\)" "\\$\[0-9\]+ = 3" \ -+ "print ar1\(3\)" -+ -+# Tests for subranges of 2 dimensional arrays with subrange variations -+gdb_test "print ar2\(2:3, 3:4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 23, 33\\) \\( 24, 34\\) \\)" \ -+ "print ar2\(2:3, 3:4\)." -+gdb_test "print ar2\(8:9,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ -+ "print ar2\(8:9,8:\)" -+gdb_test "print ar2\(8:9,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \ -+ "print ar2\(8:9,:2\)" -+ -+gdb_test "print ar2\(8:,8:9\)" \ -+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ -+ "print ar2\(8:,8:9\)" -+gdb_test "print ar2\(8:,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ -+ "print ar2\(8:,8:\)" -+gdb_test "print ar2\(8:,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \ -+ "print ar2\(8:,:2\)" -+ -+gdb_test "print ar2\(:2,2:3\)" \ -+ "\\$\[0-9\]+ = \\(\\( 12, 22\\) \\( 13, 23\\) \\)" \ -+ "print ar2\(:2,2:3\)" -+gdb_test "print ar2\(:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 18, 28\\) \\( 19, 29\\) \\)" \ -+ "print ar2\(:2,8:\)" -+gdb_test "print ar2\(:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 11, 21\\) \\( 12, 22\\) \\)" \ -+ "print ar2\(:2,:2\)" -+ -+# Test subranges of 2 dimensional arrays with literals and subrange variations -+gdb_test "print ar2\(7, 3:6\)" \ -+ "\\$\[0-9\]+ = \\(73, 74, 75, 76\\)" \ -+ "print ar2\(7, 3:6\)" -+gdb_test "print ar2\(7,8:\)" \ -+ "\\$\[0-9\]+ = \\(78, 79\\)" \ -+ "print ar2\(7,8:\)" -+gdb_test "print ar2\(7,:2\)" \ -+ "\\$\[0-9\]+ = \\(71, 72\\)" \ -+ "print ar2\(7,:2\)" -+ -+gdb_test "print ar2\(7:8,4\)" \ -+ "\\$\[0-9\]+ = \\(74, 84\\)" \ -+ "print ar2(7:8,4\)" -+gdb_test "print ar2\(8:,4\)" \ -+ "\\$\[0-9\]+ = \\(84, 94\\)" \ -+ "print ar2\(8:,4\)" -+gdb_test "print ar2\(:2,4\)" \ -+ "\\$\[0-9\]+ = \\(14, 24\\)" \ -+ "print ar2\(:2,4\)" -+gdb_test "print ar2\(3,4\)" \ -+ "\\$\[0-9\]+ = 34" \ -+ "print ar2\(3,4\)" -+ -+# Test subarrays of 3 dimensional arrays with literals and subrange variations -+gdb_test "print ar3\(2:4,3:4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 237, 337, 437\\) \\( 247, 347, 447\\)\ -+ \\) \\( \\( 238, 338, 438\\) \\( 248, 348, 448\\) \\) \\)" \ -+ "print ar3\(2:4,3:4,7:8\)" -+gdb_test "print ar3\(2:3,4:5,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 248, 348\\) \\( 258, 358\\) \\) \\(\ -+ \\( 249, 349\\) \\( 259, 359\\) \\) \\)" \ -+ "print ar3\(2:3,4:5,8:\)" -+gdb_test "print ar3\(2:3,4:5,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 241, 341\\) \\( 251, 351\\) \\) \\(\ -+ \\( 242, 342\\) \\( 252, 352\\) \\) \\)" \ -+ "print ar3\(2:3,4:5,:2\)" -+ -+gdb_test "print ar3\(2:3,8:,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 287, 387\\) \\( 297, 397\\) \\) \\(\ -+ \\( 288, 388\\) \\( 298, 398\\) \\) \\)" \ -+ "print ar3\(2:3,8:,7:8\)" -+gdb_test "print ar3\(2:3,8:,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 288, 388\\) \\( 298, 398\\) \\) \\(\ -+ \\( 289, 389\\) \\( 299, 399\\) \\) \\)" \ -+ "print ar3\(2:3,8:,8:\)" -+gdb_test "print ar3\(2:3,8:,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 281, 381\\) \\( 291, 391\\) \\) \\(\ -+ \\( 282, 382\\) \\( 292, 392\\) \\) \\)" \ -+ "print ar3\(2:3,8:,:2\)" -+ -+gdb_test "print ar3\(2:3,:2,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 217, 317\\) \\( 227, 327\\) \\) \\(\ -+ \\( 218, 318\\) \\( 228, 328\\) \\) \\)" \ -+ "print ar3\(2:3,:2,7:8\)" -+gdb_test "print ar3\(2:3,:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 218, 318\\) \\( 228, 328\\) \\) \\(\ -+ \\( 219, 319\\) \\( 229, 329\\) \\) \\)" \ -+ "print ar3\(2:3,:2,8:\)" -+gdb_test "print ar3\(2:3,:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 211, 311\\) \\( 221, 321\\) \\) \\(\ -+ \\( 212, 312\\) \\( 222, 322\\) \\) \\)" \ -+ "print ar3\(2:3,:2,:2\)" -+ -+gdb_test "print ar3\(8:,3:4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 837, 937\\) \\( 847, 947\\) \\) \\(\ -+ \\( 838, 938\\) \\( 848, 948\\) \\) \\)" \ -+ "print ar3\(8:,3:4,7:8\)" -+gdb_test "print ar3\(8:,4:5,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 848, 948\\) \\( 858, 958\\) \\) \\(\ -+ \\( 849, 949\\) \\( 859, 959\\) \\) \\)" \ -+ "print ar3\(8:,4:5,8:\)" -+gdb_test "print ar3\(8:,4:5,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 841, 941\\) \\( 851, 951\\) \\) \\(\ -+ \\( 842, 942\\) \\( 852, 952\\) \\) \\)" \ -+ "print ar3\(8:,4:5,:2\)" -+ -+gdb_test "print ar3\(8:,8:,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 887, 987\\) \\( 897, 997\\) \\) \\(\ -+ \\( 888, 988\\) \\( 898, 998\\) \\) \\)" \ -+ "print ar3\(8:,8:,7:8\)" -+gdb_test "print ar3\(8:,8:,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 888, 988\\) \\( 898, 998\\) \\) \\(\ -+ \\( 889, 989\\) \\( 899, 999\\) \\) \\)" \ -+ "print ar3\(8:,8:,8:\)" -+gdb_test "print ar3\(8:,8:,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 881, 981\\) \\( 891, 991\\) \\) \\(\ -+ \\( 882, 982\\) \\( 892, 992\\) \\) \\)" \ -+ "print ar3\(8:,8:,:2\)" -+ -+gdb_test "print ar3\(8:,:2,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 817, 917\\) \\( 827, 927\\) \\) \\(\ -+ \\( 818, 918\\) \\( 828, 928\\) \\) \\)" \ -+ "print ar3\(8:,:2,7:8\)" -+gdb_test "print ar3\(8:,:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 818, 918\\) \\( 828, 928\\) \\) \\(\ -+ \\( 819, 919\\) \\( 829, 929\\) \\) \\)" \ -+ "print ar3\(8:,:2,8:\)" -+gdb_test "print ar3\(8:,:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 811, 911\\) \\( 821, 921\\) \\) \\(\ -+ \\( 812, 912\\) \\( 822, 922\\) \\) \\)" \ -+ "print ar3\(8:,:2,:2\)" -+ -+ -+gdb_test "print ar3\(:2,3:4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 137, 237\\) \\( 147, 247\\) \\) \\(\ -+ \\( 138, 238\\) \\( 148, 248\\) \\) \\)" \ -+ "print ar3 \(:2,3:4,7:8\)." -+gdb_test "print ar3\(:2,3:4,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 138, 238\\) \\( 148, 248\\) \\) \\(\ -+ \\( 139, 239\\) \\( 149, 249\\) \\) \\)" \ -+ "print ar3\(:2,3:4,8:\)" -+gdb_test "print ar3\(:2,3:4,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 131, 231\\) \\( 141, 241\\) \\) \\(\ -+ \\( 132, 232\\) \\( 142, 242\\) \\) \\)" \ -+ "print ar3\(:2,3:4,:2\)" -+ -+gdb_test "print ar3\(:2,8:,7:8\)" "\\$\[0-9\]+ = \\(\\( \\( 187, 287\\) \\(\ -+ 197, 297\\) \\) \\( \\( 188, 288\\) \\( 198, 298\\) \\) \\)" \ -+ "print ar3\(:2,8:,7:8\)" -+gdb_test "print ar3\(:2,8:,8:\)" "\\$\[0-9\]+ = \\(\\( \\( 188, 288\\) \\( 198,\ -+ 298\\) \\) \\( \\( 189, 289\\) \\( 199, 299\\) \\) \\)" \ -+ "print ar3\(:2,8:,8:\)" -+gdb_test "print ar3\(:2,8:,:2\)" "\\$\[0-9\]+ = \\(\\( \\( 181, 281\\) \\( 191,\ -+ 291\\) \\) \\( \\( 182, 282\\) \\( 192, 292\\) \\) \\)" \ -+ "print ar3\(:2,8:,:2\)" -+ -+gdb_test "print ar3\(:2,:2,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 117, 217\\) \\( 127, 227\\) \\) \\(\ -+ \\( 118, 218\\) \\( 128, 228\\) \\) \\)" \ -+ "print ar3\(:2,:2,7:8\)" -+gdb_test "print ar3\(:2,:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 118, 218\\) \\( 128, 228\\) \\) \\(\ -+ \\( 119, 219\\) \\( 129, 229\\) \\) \\)" \ -+ "print ar3\(:2,:2,8:\)" -+gdb_test "print ar3\(:2,:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\) \\(\ -+ \\( 112, 212\\) \\( 122, 222\\) \\) \\)" \ -+ "print ar3\(:2,:2,:2\)" -+ -+#Tests for subarrays of 3 dimensional arrays with literals and subranges -+gdb_test "print ar3\(3,3:4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 337, 347\\) \\( 338, 348\\) \\)" \ -+ "print ar3\(3,3:4,7:8\)" -+gdb_test "print ar3\(3,4:5,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 348, 358\\) \\( 349, 359\\) \\)" \ -+ "print ar3\(3,4:5,8:\)" -+gdb_test "print ar3\(3,4:5,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 341, 351\\) \\( 342, 352\\) \\)" \ -+ "print ar3\(3,4:5,:2\)" -+gdb_test "print ar3\(3,4:5,3\)" \ -+ "\\$\[0-9\]+ = \\(343, 353\\)" \ -+ "print ar3\(3,4:5,3\)" -+ -+gdb_test "print ar3\(2,8:,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 287, 297\\) \\( 288, 298\\) \\)" \ -+ "print ar3\(2,8:,7:8\)" -+gdb_test "print ar3\(2,8:,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 288, 298\\) \\( 289, 299\\) \\)" \ -+ "print ar3\(2,8:,8:\)" -+gdb_test "print ar3\(2,8:,:2\)"\ -+ "\\$\[0-9\]+ = \\(\\( 281, 291\\) \\( 282, 292\\) \\)" \ -+ "print ar3\(2,8:,:2\)" -+gdb_test "print ar3\(2,8:,3\)" \ -+ "\\$\[0-9\]+ = \\(283, 293\\)" \ -+ "print ar3\(2,8:,3\)" -+ -+gdb_test "print ar3\(2,:2,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 217, 227\\) \\( 218, 228\\) \\)" \ -+ "print ar3\(2,:2,7:8\)" -+gdb_test "print ar3\(2,:2,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 218, 228\\) \\( 219, 229\\) \\)" \ -+ "print ar3\(2,:2,8:\)" -+gdb_test "print ar3\(2,:2,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 211, 221\\) \\( 212, 222\\) \\)" \ -+ "print ar3\(2,:2,:2\)" -+gdb_test "print ar3\(2,:2,3\)" \ -+ "\\$\[0-9\]+ = \\(213, 223\\)" \ -+ "print ar3\(2,:2,3\)" -+ -+gdb_test "print ar3\(3,4,7:8\)" \ -+ "\\$\[0-9\]+ = \\(347, 348\\)" \ -+ "print ar3\(3,4,7:8\)" -+gdb_test "print ar3\(3,4,8:\)" \ -+ "\\$\[0-9\]+ = \\(348, 349\\)" \ -+i "print ar3\(3,4,8:\)" -+gdb_test "print ar3\(3,4,:2\)" \ -+ "\\$\[0-9\]+ = \\(341, 342\\)" \ -+ "print ar3\(3,4,:2\)" -+gdb_test "print ar3\(5,6,7\)" \ -+ "\\$\[0-9\]+ = 567" \ -+ "print ar3\(5,6,7\)" -+ -+gdb_test "print ar3\(3:4,6,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 367, 467\\) \\( 368, 468\\) \\)" \ -+ "print ar3\(3:4,6,7:8\)" -+gdb_test "print ar3\(3:4,6,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 368, 468\\) \\( 369, 469\\) \\)" \ -+ "print ar3\(3:4,6,8:\)" -+gdb_test "print ar3\(3:4,6,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 361, 461\\) \\( 362, 462\\) \\)" \ -+ "print ar3\(3:4,6,:2\)" -+gdb_test "print ar3\(3:4,6,5\)" \ -+ "\\$\[0-9\]+ = \\(365, 465\\)" \ -+ "print ar3\(3:4,6,5\)" -+ -+gdb_test "print ar3\(8:,6,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 867, 967\\) \\( 868, 968\\) \\)" \ -+ "print ar3\(8:,6,7:8\)" -+gdb_test "print ar3\(8:,6,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 868, 968\\) \\( 869, 969\\) \\)" \ -+ "print ar3\(8:,6,8:\)" -+gdb_test "print ar3\(8:,6,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 861, 961\\) \\( 862, 962\\) \\)" \ -+ "print ar3\(8:,6,:2\)" -+gdb_test "print ar3\(8:,6,5\)" \ -+ "\\$\[0-9\]+ = \\(865, 965\\)" \ -+ "print ar3\(8:,6,5\)" -+ -+gdb_test "print ar3\(:2,6,7:8\)" \ -+ "\\$\[0-9\]+ = \\(\\( 167, 267\\) \\( 168, 268\\) \\)" \ -+ "print ar3\(:2,6,7:8\)" -+gdb_test "print ar3\(:2,6,8:\)" \ -+ "\\$\[0-9\]+ = \\(\\( 168, 268\\) \\( 169, 269\\) \\)" \ -+ "print ar3\(:2,6,8:\)" -+gdb_test "print ar3\(:2,6,:2\)" \ -+ "\\$\[0-9\]+ = \\(\\( 161, 261\\) \\( 162, 262\\) \\)" \ -+ "print ar3\(:2,6,:2\)" -+gdb_test "print ar3\(:2,6,5\)" \ -+ "\\$\[0-9\]+ = \\(165, 265\\)" \ -+ "print ar3\(:2,6,5\)" -+ -+gdb_test "print ar3\(3:4,5:6,4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 354, 454\\) \\( 364, 464\\) \\)" \ -+ "print ar2\(3:4,5:6,4\)" -+gdb_test "print ar3\(8:,5:6,4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 854, 954\\) \\( 864, 964\\) \\)" \ -+ "print ar2\(8:,5:6,4\)" -+gdb_test "print ar3\(:2,5:6,4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 154, 254\\) \\( 164, 264\\) \\)" \ -+ "print ar2\(:2,5:6,4\)" -+ -+# Stride > 1 -+gdb_test "print ar1\(2:6:2\)" \ -+ "\\$\[0-9\]+ = \\(2, 4, 6\\)" \ -+ "print ar1\(2:6:2\)" -+gdb_test "print ar2\(2:6:2,3:4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 23, 43, 63\\) \\( 24, 44, 64\\) \\)" \ -+ "print ar2\(2:6:2,3:4\)" -+gdb_test "print ar2\(2:6:2,3\)" \ -+ "\\$\[0-9\]+ = \\(23, 43, 63\\)" \ -+ "print ar2\(2:6:2,3\)" -+gdb_test "print ar3\(2:6:2,3:5:2,4:7:3\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 234, 434, 634\\) \\( 254, 454, 654\\)\ -+ \\) \\( \\( 237, 437, 637\\) \\( 257, 457, 657\\) \\) \\)" \ -+ "print ar3\(2:6:2,3:5:2,4:7:3\)" -+gdb_test "print ar3\(2:6:2,5,4:7:3\)" \ -+ "\\$\[0-9\]+ = \\(\\( 254, 454, 654\\) \\( 257, 457, 657\\)\ -+ \\)" \ -+ "print ar3\(2:6:2,5,4:7:3\)" -+ -+# Stride < 0 -+gdb_test "print ar1\(8:2:-2\)" \ -+ "\\$\[0-9\]+ = \\(8, 6, 4, 2\\)" \ -+ "print ar1\(8:2:-2\)" -+gdb_test "print ar2\(8:2:-2,3:4\)" \ -+ "\\$\[0-9\]+ = \\(\\( 83, 63, 43, 23\\) \\( 84, 64, 44, 24\\)\ -+ \\)" \ -+ "print ar2\(8:2:-2,3:4\)" -+gdb_test "print ar2\(2:6:2,3\)" \ -+ "\\$\[0-9\]+ = \\(23, 43, 63\\)" \ -+ "print ar2\(2:6:2,3\)" -+gdb_test "print ar3\(2:3,7:3:-4,4:7:3\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 274, 374\\) \\( 234, 334\\) \\) \\(\ -+ \\( 277, 377\\) \\( 237, 337\\) \\) \\)" \ -+ "print ar3\(2:3,7:3:-4,4:7:3\)" -+gdb_test "print ar3\(2:6:2,5,7:4:-3\)" \ -+ "\\$\[0-9\]+ = \\(\\( 257, 457, 657\\) \\( 254, 454, 654\\)\ -+ \\)" \ -+ "print ar3\(2:6:2,5,7:4:-3\)" -+ -+# Tests with negative and mixed indices -+gdb_test "p ar4\(2:4, -2:1, -15:-14\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 261, 361, 461\\) \\( 271, 371, 471\\)\ -+ \\( 281, 381, 481\\) \\( 291, 391, 491\\) \\) \\( \\( 262,\ -+ 362, 462\\) \\( 272, 372, 472\\) \\( 282, 382, 482\\) \\( 292,\ -+ 392, 492\\) \\) \\)" \ -+ "print ar4(2:4, -2:1, -15:-14)" -+ -+gdb_test "p ar4\(7,-6:2:3,-7\)" \ -+ "\\$\[0-9\]+ = \\(729, 759, 789\\)" \ -+ "print ar4(7,-6:2:3,-7)" -+ -+gdb_test "p ar4\(9:2:-2, -6:2:3, -6:-15:-3\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 930, 730, 530, 330\\) \\( 960, 760,\ -+ 560, 360\\) \\( 990, 790, 590, 390\\) \\) \\( \\( 927, 727,\ -+ 527, 327\\) \\( 957, 757, 557, 357\\) \\( 987, 787, 587,\ -+ 387\\) \\) \\( \\( 924, 724, 524, 324\\) \\( 954, 754, 554,\ -+ 354\\) \\( 984, 784, 584, 384\\) \\) \\( \\( 921, 721, 521,\ -+ 321\\) \\( 951, 751, 551, 351\\) \\( 981, 781, 581, 381\\) \\)\ -+ \\)" \ -+ "print ar4(9:2:-2, -6:2:3, -6:-15:-3)" -+ -+gdb_test "p ar4\(:,:,:\)" \ -+ "\\$\[0-9\]+ = \\(\\( \\( 111, 211, 311, 411, 511, 611, 711,\ -+ 811, .*" \ -+ "print ar4(:,:,:)" -+ -+# Provoke error messages for bad user input -+gdb_test "print ar1\(0:4\)" \ -+ "provided bound\\(s\\) outside array bound\\(s\\)" \ -+ "print ar1\(0:4\)" -+gdb_test "print ar1\(8:12\)" \ -+ "provided bound\\(s\\) outside array bound\\(s\\)" \ -+ "print ar1\(8:12\)" -+gdb_test "print ar1\(8:2:\)" \ -+ "A syntax error in expression, near `\\)'." \ -+ "print ar1\(8:2:\)" -+gdb_test "print ar1\(8:2:2\)" \ -+ "Wrong value provided for stride and boundaries" \ -+ "print ar1\(8:2:2\)" -+gdb_test "print ar1\(2:8:-2\)" \ -+ "Wrong value provided for stride and boundaries" \ -+ "print ar1\(2:8:-2\)" -+gdb_test "print ar1\(2:7:0\)" \ -+ "Stride must not be 0" \ -+ "print ar1\(2:7:0\)" -+gdb_test "print ar1\(3:7\) = 42" \ -+ "Invalid cast." \ -+ "Assignment of value to subarray" -diff --git a/gdb/testsuite/gdb.fortran/static-arrays.f90 b/gdb/testsuite/gdb.fortran/static-arrays.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/static-arrays.f90 -@@ -0,0 +1,55 @@ -+! Copyright 2015 Free Software Foundation, Inc. -+! -+! Contributed by Intel Corp. -+! -+! This program is free software; you can redistribute it and/or modify -+! it under the terms of the GNU General Public License as published by -+! the Free Software Foundation; either version 3 of the License, or -+! (at your option) any later version. -+! -+! This program is distributed in the hope that it will be useful, -+! but WITHOUT ANY WARRANTY; without even the implied warranty of -+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+! GNU General Public License for more details. -+! -+! You should have received a copy of the GNU General Public License -+! along with this program. If not, see . -+ -+subroutine sub -+ integer, dimension(9) :: ar1 -+ integer, dimension(9,9) :: ar2 -+ integer, dimension(9,9,9) :: ar3 -+ integer, dimension(10,-7:3, -15:-5) :: ar4 -+ integer :: i,j,k -+ -+ ar1 = 1 -+ ar2 = 1 -+ ar3 = 1 -+ ar4 = 4 -+ -+ ! Resulting array ar3 looks like ((( 111, 112, 113, 114,...))) -+ do i = 1, 9, 1 -+ ar1(i) = i -+ do j = 1, 9, 1 -+ ar2(i,j) = i*10 + j -+ do k = 1, 9, 1 -+ ar3(i,j,k) = i*100 + j*10 + k -+ end do -+ end do -+ end do -+ -+ do i = 1, 10, 1 -+ do j = -7, 3, 1 -+ do k = -15, -5, 1 -+ ar4(i,j,k) = i*100 + (j+8)*10 + (k+16) -+ end do -+ end do -+ end do -+ -+ ar1(1) = 11 !BP1 -+ return -+end -+ -+program testprog -+ call sub -+end -diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp ---- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp -+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp -@@ -32,7 +32,8 @@ gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1" - gdb_test "print sizeof(vla1(3,2,1))" \ - "no such vector element \\(vector not allocated\\)" \ - "print sizeof non-allocated indexed vla1" --gdb_test "print sizeof(vla1(3:4,2,1))" "array not allocated" \ -+gdb_test "print sizeof(vla1(3:4,2,1))" \ -+ "provided bound\\(s\\) outside array bound\\(s\\)" \ - "print sizeof non-allocated sliced vla1" - - # Try to access value in allocated VLA -@@ -41,7 +42,7 @@ gdb_continue_to_breakpoint "vla1-allocated" - gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1" - gdb_test "print sizeof(vla1(3,2,1))" "4" \ - "print sizeof element from allocated vla1" --gdb_test "print sizeof(vla1(3:4,2,1))" "800" \ -+gdb_test "print sizeof(vla1(3:4,2,1))" "8" \ - "print sizeof sliced vla1" - - # Try to access values in undefined pointer to VLA (dangling) -@@ -49,7 +50,8 @@ gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla" - gdb_test "print sizeof(pvla(3,2,1))" \ - "no such vector element \\(vector not associated\\)" \ - "print sizeof non-associated indexed pvla" --gdb_test "print sizeof(pvla(3:4,2,1))" "array not associated" \ -+gdb_test "print sizeof(pvla(3:4,2,1))" \ -+ "provided bound\\(s\\) outside array bound\\(s\\)" \ - "print sizeof non-associated sliced pvla" - - # Try to access values in pointer to VLA and compare them -@@ -58,7 +60,8 @@ gdb_continue_to_breakpoint "pvla-associated" - gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla" - gdb_test "print sizeof(pvla(3,2,1))" "4" \ - "print sizeof element from associated pvla" --gdb_test "print sizeof(pvla(3:4,2,1))" "800" "print sizeof sliced pvla" -+ -+gdb_test "print sizeof(pvla(3:4,2,1))" "8" "print sizeof sliced pvla" - - gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds-v1"] - gdb_continue_to_breakpoint "vla1-neg-bounds-v1" -diff --git a/gdb/testsuite/gdb.fortran/vla-stride.exp b/gdb/testsuite/gdb.fortran/vla-stride.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-stride.exp -@@ -0,0 +1,47 @@ -+# Copyright 2016 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+standard_testfile ".f90" -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ -+ {debug f90 quiet}] } { -+ return -1 -+} -+ -+if ![runto MAIN__] then { -+ perror "couldn't run to breakpoint MAIN__" -+ continue -+} -+ -+gdb_test_no_output "set max-value-size unlimited" \ -+ "set max-value-size to unlimited" -+ -+gdb_breakpoint [gdb_get_line_number "re-reverse-elements"] -+gdb_continue_to_breakpoint "re-reverse-elements" -+gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \ -+ "print re-reverse-elements" -+gdb_test "print pvla(1)" " = 1" "print first re-reverse-element" -+gdb_test "print pvla(10)" " = 10" "print last re-reverse-element" -+ -+gdb_breakpoint [gdb_get_line_number "odd-elements"] -+gdb_continue_to_breakpoint "odd-elements" -+gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements" -+gdb_test "print pvla(1)" " = 1" "print first odd-element" -+gdb_test "print pvla(5)" " = 9" "print last odd-element" -+ -+gdb_breakpoint [gdb_get_line_number "single-element"] -+gdb_continue_to_breakpoint "single-element" -+gdb_test "print pvla" " = \\\(5\\\)" "print single-element" -+gdb_test "print pvla(1)" " = 5" "print one single-element" -diff --git a/gdb/testsuite/gdb.fortran/vla-stride.f90 b/gdb/testsuite/gdb.fortran/vla-stride.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-stride.f90 -@@ -0,0 +1,29 @@ -+! Copyright 2016 Free Software Foundation, Inc. -+! -+! This program is free software; you can redistribute it and/or modify -+! it under the terms of the GNU General Public License as published by -+! the Free Software Foundation; either version 3 of the License, or -+! (at your option) any later version. -+! -+! This program is distributed in the hope that it will be useful, -+! but WITHOUT ANY WARRANTY; without even the implied warranty of -+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+! GNU General Public License for more details. -+! -+! You should have received a copy of the GNU General Public License -+! along with this program. If not, see . -+ -+program vla_stride -+ integer, target, allocatable :: vla (:) -+ integer, pointer :: pvla (:) -+ -+ allocate(vla(10)) -+ vla = (/ (I, I = 1,10) /) -+ -+ pvla => vla(10:1:-1) -+ pvla => pvla(10:1:-1) -+ pvla => vla(1:10:2) ! re-reverse-elements -+ pvla => vla(5:4:-2) ! odd-elements -+ -+ pvla => null() ! single-element -+end program vla_stride -diff --git a/gdb/valops.c b/gdb/valops.c ---- a/gdb/valops.c -+++ b/gdb/valops.c -@@ -3797,13 +3797,42 @@ value_of_this_silent (const struct language_defn *lang) - - struct value * - value_slice (struct value *array, int lowbound, int length) -+{ -+ /* Pass unaltered arguments to VALUE_SLICE_1, plus a default stride -+ value of '1', which returns every element between LOWBOUND and -+ (LOWBOUND + LENGTH). We also provide a default CALL_COUNT of '1' -+ as we are only considering the highest dimension, or we are -+ working on a one dimensional array. So we call VALUE_SLICE_1 -+ exactly once. */ -+ return value_slice_1 (array, lowbound, length, 1, 1); -+} -+ -+/* VALUE_SLICE_1 is called for each array dimension to calculate the number -+ of elements as defined by the subscript expression. -+ CALL_COUNT is used to determine if we are calling the function once, e.g. -+ we are working on the current dimension of ARRAY, or if we are calling -+ the function repeatedly. In the later case we need to take elements -+ from the TARGET_TYPE of ARRAY. -+ With a CALL_COUNT greater than 1 we calculate the offsets for every element -+ that should be in the result array. Then we fetch the contents and then -+ copy them into the result array. The result array will have one dimension -+ less than the input array, so later on we need to recreate the indices and -+ ranges in the calling function. */ -+ -+struct value * -+value_slice_1 (struct value *array, int lowbound, int length, -+ int stride_length, int call_count) - { - struct type *slice_range_type, *slice_type, *range_type; -- LONGEST lowerbound, upperbound; -- struct value *slice; -- struct type *array_type; -+ struct type *array_type = check_typedef (value_type (array)); -+ struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type)); -+ unsigned int elt_size, elt_offs; -+ LONGEST ary_high_bound, ary_low_bound; -+ struct value *v; -+ int slice_range_size, i = 0, row_count = 1, elem_count = 1; - -- array_type = check_typedef (value_type (array)); -+ /* Check for legacy code if we are actually dealing with an array or -+ string. */ - if (TYPE_CODE (array_type) != TYPE_CODE_ARRAY - && TYPE_CODE (array_type) != TYPE_CODE_STRING) - error (_("cannot take slice of non-array")); -@@ -3813,45 +3842,155 @@ value_slice (struct value *array, int lowbound, int length) - if (type_not_associated (array_type)) - error (_("array not associated")); - -- range_type = TYPE_INDEX_TYPE (array_type); -- if (get_discrete_bounds (range_type, &lowerbound, &upperbound) < 0) -- error (_("slice from bad array or bitstring")); -+ ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (array_type)); -+ ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (array_type)); -+ -+ /* When we are working on a multi-dimensional array, we need to get the -+ attributes of the underlying type. */ -+ if (call_count > 1) -+ { -+ ary_low_bound = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (elt_type)); -+ ary_high_bound = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (elt_type)); -+ elt_type = check_typedef (TYPE_TARGET_TYPE (elt_type)); -+ row_count = TYPE_LENGTH (array_type) -+ / TYPE_LENGTH (TYPE_TARGET_TYPE (array_type)); -+ } -+ -+ /* With a stride of '1', the number of elements per result row is equal to -+ the LENGTH of the subarray. With non-default stride values, we skip -+ elements, but have to add the start element to the total number of -+ elements per row. */ -+ if (stride_length == 1) -+ elem_count = length; -+ else -+ elem_count = ((length - 1) / stride_length) + 1; -+ -+ elt_size = TYPE_LENGTH (elt_type); -+ elt_offs = lowbound - ary_low_bound; - -- if (lowbound < lowerbound || length < 0 -- || lowbound + length - 1 > upperbound) -- error (_("slice out of range")); -+ elt_offs *= elt_size; -+ -+ /* Check for valid user input. In case of Fortran this was already done -+ in the calling function. */ -+ if (call_count == 1 -+ && (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type) -+ && elt_offs >= TYPE_LENGTH (array_type))) -+ error (_("no such vector element")); -+ -+ /* CALL_COUNT is 1 when we are dealing either with the highest dimension -+ of the array, or a one dimensional array. Set RANGE_TYPE accordingly. -+ In both cases we calculate how many rows/elements will be in the output -+ array by setting slice_range_size. */ -+ if (call_count == 1) -+ { -+ range_type = TYPE_INDEX_TYPE (array_type); -+ slice_range_size = ary_low_bound + elem_count - 1; -+ -+ /* Check if the array bounds are valid. */ -+ if (get_discrete_bounds (range_type, &ary_low_bound, &ary_high_bound) < 0) -+ error (_("slice from bad array or bitstring")); -+ } -+ /* When CALL_COUNT is greater than 1, we are dealing with an array of arrays. -+ So we need to get the type below the current one and set the RANGE_TYPE -+ accordingly. */ -+ else -+ { -+ range_type = TYPE_INDEX_TYPE (TYPE_TARGET_TYPE (array_type)); -+ slice_range_size = ary_low_bound + (row_count * elem_count) - 1; -+ ary_low_bound = TYPE_LOW_BOUND (range_type); -+ } - - /* FIXME-type-allocation: need a way to free this type when we are -- done with it. */ -- slice_range_type = create_static_range_type (NULL, -- TYPE_TARGET_TYPE (range_type), -- lowbound, -- lowbound + length - 1); -+ done with it. */ - -+ slice_range_type = create_static_range_type (NULL, TYPE_TARGET_TYPE (range_type), -+ ary_low_bound, slice_range_size); - { -- struct type *element_type = TYPE_TARGET_TYPE (array_type); -- LONGEST offset -- = (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type)); -+ struct type *element_type; -+ -+ /* When both CALL_COUNT and STRIDE_LENGTH equal 1, we can use the legacy -+ code for subarrays. */ -+ if (call_count == 1 && stride_length == 1) -+ { -+ element_type = TYPE_TARGET_TYPE (array_type); -+ -+ slice_type = create_array_type (NULL, element_type, slice_range_type); - -- slice_type = create_array_type (NULL, -- element_type, -- slice_range_type); -- TYPE_CODE (slice_type) = TYPE_CODE (array_type); -+ TYPE_CODE (slice_type) = TYPE_CODE (array_type); - -- if (VALUE_LVAL (array) == lval_memory && value_lazy (array)) -- slice = allocate_value_lazy (slice_type); -+ if (VALUE_LVAL (array) == lval_memory && value_lazy (array)) -+ v = allocate_value_lazy (slice_type); -+ else -+ { -+ v = allocate_value (slice_type); -+ value_contents_copy (v, -+ value_embedded_offset (v), -+ array, -+ value_embedded_offset (array) + elt_offs, -+ elt_size * longest_to_int (length)); -+ } -+ -+ } -+ /* With a CALL_COUNT or STRIDE_LENGTH are greater than 1 we are working -+ on a range of ranges. So we copy the relevant elements into the -+ new array we return. */ - else - { -- slice = allocate_value (slice_type); -- value_contents_copy (slice, 0, array, offset, -- type_length_units (slice_type)); -+ int j, offs_store = elt_offs; -+ LONGEST dst_offset = 0; -+ LONGEST src_row_length = TYPE_LENGTH (TYPE_TARGET_TYPE (array_type)); -+ -+ if (call_count == 1) -+ { -+ /* When CALL_COUNT is equal to 1 we are working on the current range -+ and use these elements directly. */ -+ element_type = TYPE_TARGET_TYPE (array_type); -+ } -+ else -+ { -+ /* Working on an array of arrays, the type of the elements is the type -+ of the subarrays' type. */ -+ element_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (array_type)); -+ } -+ -+ slice_type = create_array_type (NULL, element_type, slice_range_type); -+ -+ /* If we have a one dimensional array, we copy its TYPE_CODE. For a -+ multi dimensional array we copy the embedded type's TYPE_CODE. */ -+ if (call_count == 1) -+ TYPE_CODE (slice_type) = TYPE_CODE (array_type); -+ else -+ TYPE_CODE (slice_type) = TYPE_CODE (TYPE_TARGET_TYPE (array_type)); -+ -+ v = allocate_value (slice_type); -+ -+ /* Iterate through the rows of the outer array and set the new offset -+ for each row. */ -+ for (i = 0; i < row_count; i++) -+ { -+ elt_offs = offs_store + i * src_row_length; -+ -+ /* Iterate through the elements in each row to copy only those. */ -+ for (j = 1; j <= elem_count; j++) -+ { -+ /* Fetches the contents of ARRAY and copies them into V. */ -+ value_contents_copy (v, dst_offset, array, elt_offs, elt_size); -+ elt_offs += elt_size * stride_length; -+ dst_offset += elt_size; -+ } -+ } - } - -- set_value_component_location (slice, array); -- set_value_offset (slice, value_offset (array) + offset); -+ set_value_component_location (v, array); -+ if (VALUE_LVAL (v) == lval_register) -+ { -+ VALUE_REGNUM (v) = VALUE_REGNUM (array); -+ VALUE_NEXT_FRAME_ID (v) = VALUE_NEXT_FRAME_ID (array); -+ } -+ set_value_offset (v, value_offset (array) + elt_offs); - } - -- return slice; -+ return v; - } - - /* Create a value for a FORTRAN complex number. Currently most of the -diff --git a/gdb/value.h b/gdb/value.h ---- a/gdb/value.h -+++ b/gdb/value.h -@@ -1145,6 +1145,8 @@ extern struct value *varying_to_slice (struct value *); - - extern struct value *value_slice (struct value *, int, int); - -+extern struct value *value_slice_1 (struct value *, int, int, int, int); -+ - extern struct value *value_literal_complex (struct value *, struct value *, - struct type *); - diff --git a/gdb-vla-intel-fortran-vla-strings.patch b/gdb-vla-intel-fortran-vla-strings.patch deleted file mode 100644 index deea4b5..0000000 --- a/gdb-vla-intel-fortran-vla-strings.patch +++ /dev/null @@ -1,1117 +0,0 @@ -From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 -From: Fedora GDB patches -Date: Fri, 27 Oct 2017 21:07:50 +0200 -Subject: gdb-vla-intel-fortran-vla-strings.patch - -;;=push - -git diff --stat -p gdb/master...gdb/users/bheckel/fortran-vla-strings -0ad7d8d1a3a36c6e04e3b6d37d8825f18d595723 - - gdb/NEWS | 2 + - gdb/c-valprint.c | 22 +++++ - gdb/dwarf2read.c | 158 +++++++++++++++++++++++++----- - gdb/f-typeprint.c | 93 +++++++++--------- - gdb/gdbtypes.c | 44 ++++++++- - gdb/testsuite/gdb.cp/vla-cxx.cc | 9 ++ - gdb/testsuite/gdb.cp/vla-cxx.exp | 9 ++ - gdb/testsuite/gdb.fortran/pointers.exp | 143 +++++++++++++++++++++++++++ - gdb/testsuite/gdb.fortran/pointers.f90 | 109 +++++++++++++++++++++ - gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++ - gdb/testsuite/gdb.fortran/vla-ptype.exp | 12 +-- - gdb/testsuite/gdb.fortran/vla-strings.exp | 103 +++++++++++++++++++ - gdb/testsuite/gdb.fortran/vla-strings.f90 | 39 ++++++++ - gdb/testsuite/gdb.fortran/vla-type.exp | 7 +- - gdb/testsuite/gdb.fortran/vla-value.exp | 12 ++- - gdb/testsuite/gdb.mi/mi-var-child-f.exp | 7 +- - gdb/testsuite/gdb.mi/mi-vla-fortran.exp | 27 ++--- - gdb/typeprint.c | 19 ++++ - gdb/valops.c | 16 ++- - gdb/valprint.c | 6 -- - 20 files changed, 827 insertions(+), 110 deletions(-) - -diff --git a/gdb/NEWS b/gdb/NEWS ---- a/gdb/NEWS -+++ b/gdb/NEWS -@@ -805,6 +805,8 @@ SH-5/SH64 running OpenBSD SH-5/SH64 support in sh*-*-openbsd* - - *** Changes in GDB 8.1 - -+* Fortran: Support pointers to dynamic types. -+ - * GDB now supports dynamically creating arbitrary register groups specified - in XML target descriptions. This allows for finer grain grouping of - registers on systems with a large amount of registers. -diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c ---- a/gdb/c-valprint.c -+++ b/gdb/c-valprint.c -@@ -649,6 +649,28 @@ c_value_print (struct value *val, struct ui_file *stream, - else - { - /* normal case */ -+ if (TYPE_CODE (type) == TYPE_CODE_PTR -+ && 1 == is_dynamic_type (type)) -+ { -+ CORE_ADDR addr; -+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type))) -+ addr = value_address (val); -+ else -+ addr = value_as_address (val); -+ -+ /* We resolve the target-type only when the -+ pointer is associated. */ -+ if ((addr != 0) -+ && (0 == type_not_associated (type))) -+ TYPE_TARGET_TYPE (type) = -+ resolve_dynamic_type (TYPE_TARGET_TYPE (type), -+ NULL, addr); -+ } -+ else -+ { -+ /* Do nothing. References are already resolved from the beginning, -+ only pointers are resolved when we actual need the target. */ -+ } - fprintf_filtered (stream, "("); - type_print (value_type (val), "", stream, -1); - fprintf_filtered (stream, ") "); -diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c ---- a/gdb/dwarf2read.c -+++ b/gdb/dwarf2read.c -@@ -1827,7 +1827,10 @@ static void read_signatured_type (struct signatured_type *); - - static int attr_to_dynamic_prop (const struct attribute *attr, - struct die_info *die, struct dwarf2_cu *cu, -- struct dynamic_prop *prop, struct type *type); -+ struct dynamic_prop *prop, -+ struct type *default_type, -+ const gdb_byte *additional_data, -+ int additional_data_size); - - /* memory allocation interface */ - -@@ -13799,7 +13802,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) - newobj->static_link - = XOBNEW (&objfile->objfile_obstack, struct dynamic_prop); - attr_to_dynamic_prop (attr, die, cu, newobj->static_link, -- dwarf2_per_cu_addr_type (cu->per_cu)); -+ dwarf2_per_cu_addr_type (cu->per_cu), NULL, 0); - } - - cu->list_in_scope = cu->get_builder ()->get_local_symbols (); -@@ -16565,7 +16568,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) - byte_stride_prop - = (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop)); - stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop, -- prop_type); -+ prop_type, NULL, 0); - if (!stride_ok) - { - complaint (_("unable to read array DW_AT_byte_stride " -@@ -17325,7 +17328,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - struct attribute *attr; - struct dynamic_prop prop; - bool length_is_constant = true; -- LONGEST length; -+ ULONGEST length = UINT_MAX; - - /* There are a couple of places where bit sizes might be made use of - when parsing a DW_TAG_string_type, however, no producer that we know -@@ -17346,6 +17349,10 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - } - } - -+ index_type = objfile_type (objfile)->builtin_int; -+ range_type = create_static_range_type (NULL, index_type, 1, length); -+ -+ /* If DW_AT_string_length is defined, the length is stored in memory. */ - attr = dwarf2_attr (die, DW_AT_string_length, cu); - if (attr != nullptr && !attr_form_is_constant (attr)) - { -@@ -17372,13 +17379,71 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - } - - /* Convert the attribute into a dynamic property. */ -- if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) -+ if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) - length = 1; - else - length_is_constant = false; - } - else if (attr != nullptr) - { -+ if (attr_form_is_block (attr)) -+ { -+ struct attribute *byte_size, *bit_size; -+ struct dynamic_prop high; -+ -+ byte_size = dwarf2_attr (die, DW_AT_byte_size, cu); -+ bit_size = dwarf2_attr (die, DW_AT_bit_size, cu); -+ -+ /* DW_AT_byte_size should never occur in combination with -+ DW_AT_bit_size. */ -+ if (byte_size != NULL && bit_size != NULL) -+ complaint (_("DW_AT_byte_size AND " -+ "DW_AT_bit_size found together at the same time.")); -+ -+ /* If DW_AT_string_length AND DW_AT_byte_size exist together, -+ DW_AT_byte_size describes the number of bytes that should be read -+ from the length memory location. */ -+ if (byte_size != NULL) -+ { -+ /* Build new dwarf2_locexpr_baton structure with additions to the -+ data attribute, to reflect DWARF specialities to get address -+ sizes. */ -+ const gdb_byte append_ops[] = -+ { -+ /* DW_OP_deref_size: size of an address on the target machine -+ (bytes), where the size will be specified by the next -+ operand. */ -+ DW_OP_deref_size, -+ /* Operand for DW_OP_deref_size. */ -+ (gdb_byte) DW_UNSND(byte_size) }; -+ -+ if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type, -+ append_ops, ARRAY_SIZE(append_ops))) -+ complaint (_("Could not parse DW_AT_byte_size")); -+ } -+ else if (bit_size != NULL) -+ complaint (_("DW_AT_string_length AND " -+ "DW_AT_bit_size found but not supported yet.")); -+ /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default -+ is the address size of the target machine. */ -+ else -+ { -+ const gdb_byte append_ops[] = -+ { DW_OP_deref }; -+ -+ if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type, -+ append_ops, ARRAY_SIZE(append_ops))) -+ complaint (_("Could not parse DW_AT_string_length")); -+ } -+ -+ TYPE_RANGE_DATA (range_type)->high = high; -+ } -+ else -+ { -+ TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr); -+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST; -+ } -+ - /* This DW_AT_string_length just contains the length with no - indirection. There's no need to create a dynamic property in this - case. Pass 0 for the default value as we know it will not be -@@ -17392,6 +17457,20 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - } - else - { -+ /* Check for the DW_AT_byte_size attribute, which represents the length -+ in this case. */ -+ attr = dwarf2_attr (die, DW_AT_byte_size, cu); -+ if (attr) -+ { -+ TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr); -+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST; -+ } -+ else -+ { -+ TYPE_HIGH_BOUND (range_type) = 1; -+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST; -+ } -+ - /* Use 1 as a fallback length if we have nothing else. */ - length = 1; - } -@@ -17407,6 +17486,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) - low_bound.data.const_val = 1; - range_type = create_range_type (NULL, index_type, &low_bound, &prop, 0); - } -+ - char_type = language_string_char_type (cu->language_defn, gdbarch); - type = create_string_type (NULL, char_type, range_type); - -@@ -17858,7 +17938,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) - static int - attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, - struct dwarf2_cu *cu, struct dynamic_prop *prop, -- struct type *default_type) -+ struct type *default_type, -+ const gdb_byte *additional_data, int additional_data_size) - { - struct dwarf2_property_baton *baton; - struct obstack *obstack -@@ -17885,9 +17966,30 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, - baton->locexpr.is_reference = false; - break; - } -+ -+ if (additional_data != NULL && additional_data_size > 0) -+ { -+ gdb_byte *data; -+ -+ data = (gdb_byte *) obstack_alloc( -+ &cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack, -+ DW_BLOCK (attr)->size + additional_data_size); -+ memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size); -+ memcpy (data + DW_BLOCK (attr)->size, additional_data, -+ additional_data_size); -+ -+ baton->locexpr.data = data; -+ baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size; -+ } -+ else -+ { -+ baton->locexpr.data = DW_BLOCK (attr)->data; -+ baton->locexpr.size = DW_BLOCK (attr)->size; -+ } -+ - prop->data.baton = baton; - prop->kind = PROP_LOCEXPR; -- gdb_assert (prop->data.baton != NULL); -+ gdb_assert(prop->data.baton != NULL); - } - else if (attr_form_is_ref (attr)) - { -@@ -17920,9 +18022,29 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, - baton = XOBNEW (obstack, struct dwarf2_property_baton); - baton->property_type = die_type (target_die, target_cu); - baton->locexpr.per_cu = cu->per_cu; -- baton->locexpr.size = DW_BLOCK (target_attr)->size; -- baton->locexpr.data = DW_BLOCK (target_attr)->data; - baton->locexpr.is_reference = true; -+ -+ if (additional_data != NULL && additional_data_size > 0) -+ { -+ gdb_byte *data; -+ -+ data = (gdb_byte *) obstack_alloc (&cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack, -+ DW_BLOCK (target_attr)->size + additional_data_size); -+ memcpy (data, DW_BLOCK (target_attr)->data, -+ DW_BLOCK (target_attr)->size); -+ memcpy (data + DW_BLOCK (target_attr)->size, -+ additional_data, additional_data_size); -+ -+ baton->locexpr.data = data; -+ baton->locexpr.size = (DW_BLOCK (target_attr)->size -+ + additional_data_size); -+ } -+ else -+ { -+ baton->locexpr.data = DW_BLOCK (target_attr)->data; -+ baton->locexpr.size = DW_BLOCK (target_attr)->size; -+ } -+ - prop->data.baton = baton; - prop->kind = PROP_LOCEXPR; - gdb_assert (prop->data.baton != NULL); -@@ -18099,8 +18221,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - } - - attr = dwarf2_attr (die, DW_AT_lower_bound, cu); -- if (attr != nullptr) -- attr_to_dynamic_prop (attr, die, cu, &low, base_type); -+ if (attr) -+ attr_to_dynamic_prop (attr, die, cu, &low, base_type, NULL, 0); - else if (!low_default_is_valid) - complaint (_("Missing DW_AT_lower_bound " - "- DIE at %s [in module %s]"), -@@ -18109,10 +18231,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - - struct attribute *attr_ub, *attr_count; - attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu); -- if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type)) -+ if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0)) - { - attr = attr_count = dwarf2_attr (die, DW_AT_count, cu); -- if (attr_to_dynamic_prop (attr, die, cu, &high, base_type)) -+ if (attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0)) - { - /* If bounds are constant do the final calculation here. */ - if (low.kind == PROP_CONST && high.kind == PROP_CONST) -@@ -18164,7 +18286,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - struct type *prop_type - = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); - attr_to_dynamic_prop (attr_byte_stride, die, cu, &byte_stride_prop, -- prop_type); -+ prop_type, NULL, 0); - } - - struct dynamic_prop bit_stride_prop; -@@ -18185,7 +18307,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) - struct type *prop_type - = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); - attr_to_dynamic_prop (attr_bit_stride, die, cu, &bit_stride_prop, -- prop_type); -+ prop_type, NULL, 0); - } - } - -@@ -25879,7 +26001,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - { - struct type *prop_type - = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); -- if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) -+ if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) - add_dyn_prop (DYN_PROP_ALLOCATED, prop, type); - } - else if (attr != NULL) -@@ -25895,7 +26017,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - { - struct type *prop_type - = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); -- if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) -+ if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) - add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type); - } - else if (attr != NULL) -@@ -25908,7 +26030,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu) - /* Read DW_AT_data_location and set in type. */ - attr = dwarf2_attr (die, DW_AT_data_location, cu); - if (attr_to_dynamic_prop (attr, die, cu, &prop, -- dwarf2_per_cu_addr_type (cu->per_cu))) -+ dwarf2_per_cu_addr_type (cu->per_cu), NULL, 0)) - add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type); - - if (dwarf2_per_objfile->die_type_hash == NULL) -diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c ---- a/gdb/f-typeprint.c -+++ b/gdb/f-typeprint.c -@@ -197,15 +197,14 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - print_rank_only = true; - else if ((TYPE_ASSOCIATED_PROP (type) - && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ASSOCIATED_PROP (type))) -- || (TYPE_ALLOCATED_PROP (type) -- && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type))) -- || (TYPE_DATA_LOCATION (type) -- && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type)))) -- { -- /* This case exist when we ptype a typename which has the dynamic -- properties but cannot be resolved as there is no object. */ -- print_rank_only = true; -- } -+ || (TYPE_ALLOCATED_PROP (type) -+ && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type))) -+ || (TYPE_DATA_LOCATION (type) -+ && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type)))) -+ /* This case exist when we ptype a typename which has the -+ dynamic properties but cannot be resolved as there is -+ no object. */ -+ print_rank_only = true; - - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY) - f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, -@@ -217,8 +216,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - else - { - LONGEST lower_bound = f77_get_lowerbound (type); -+ - if (lower_bound != 1) /* Not the default. */ -- fprintf_filtered (stream, "%s:", plongest (lower_bound)); -+ fprintf_filtered (stream, "%s:", plongest (lower_bound)); - - /* Make sure that, if we have an assumed size array, we - print out a warning and print the upperbound as '*'. */ -@@ -229,7 +229,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - { - LONGEST upper_bound = f77_get_upperbound (type); - -- fputs_filtered (plongest (upper_bound), stream); -+ fprintf_filtered (stream, "%s", plongest (upper_bound)); - } - } - -@@ -249,7 +249,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, - case TYPE_CODE_REF: - f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0, - arrayprint_recurse_level, false); -- fprintf_filtered (stream, " )"); -+ fprintf_filtered (stream, ")"); - break; - - case TYPE_CODE_FUNC: -diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c ---- a/gdb/gdbtypes.c -+++ b/gdb/gdbtypes.c -@@ -1939,7 +1939,8 @@ is_dynamic_type_internal (struct type *type, int top_level) - type = check_typedef (type); - - /* We only want to recognize references at the outermost level. */ -- if (top_level && TYPE_CODE (type) == TYPE_CODE_REF) -+ if (top_level && -+ (TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_PTR)) - type = check_typedef (TYPE_TARGET_TYPE (type)); - - /* Types that have a dynamic TYPE_DATA_LOCATION are considered -@@ -1972,10 +1973,10 @@ is_dynamic_type_internal (struct type *type, int top_level) - || is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0)); - } - -- case TYPE_CODE_STRING: - /* Strings are very much like an array of characters, and can be - treated as one here. */ - case TYPE_CODE_ARRAY: -+ case TYPE_CODE_STRING: - { - gdb_assert (TYPE_NFIELDS (type) == 1); - -@@ -2139,11 +2140,15 @@ resolve_dynamic_array_or_string (struct type *type, - - ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type)); - -- if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY) -+ if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY -+ || TYPE_CODE (ary_dim) == TYPE_CODE_STRING)) - elt_type = resolve_dynamic_array_or_string (ary_dim, addr_stack); - else - elt_type = TYPE_TARGET_TYPE (type); - -+ if (TYPE_CODE (type) == TYPE_CODE_STRING) -+ return create_string_type (type, elt_type, range_type); -+ - prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type); - if (prop != NULL) - { -@@ -2295,6 +2300,28 @@ resolve_dynamic_struct (struct type *type, - return resolved_type; - } - -+/* Worker for pointer types. */ -+ -+static struct type * -+resolve_dynamic_pointer (struct type *type, -+ struct property_addr_info *addr_stack) -+{ -+ struct dynamic_prop *prop; -+ CORE_ADDR value; -+ -+ type = copy_type (type); -+ -+ /* Resolve associated property. */ -+ prop = TYPE_ASSOCIATED_PROP (type); -+ if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value)) -+ { -+ TYPE_DYN_PROP_ADDR (prop) = value; -+ TYPE_DYN_PROP_KIND (prop) = PROP_CONST; -+ } -+ -+ return type; -+} -+ - /* Worker for resolved_dynamic_type. */ - - static struct type * -@@ -2349,6 +2376,9 @@ resolve_dynamic_type_internal (struct type *type, - case TYPE_CODE_ARRAY: - resolved_type = resolve_dynamic_array_or_string (type, addr_stack); - break; -+ case TYPE_CODE_PTR: -+ resolved_type = resolve_dynamic_pointer (type, addr_stack); -+ break; - - case TYPE_CODE_RANGE: - resolved_type = resolve_dynamic_range (type, addr_stack); -diff --git a/gdb/testsuite/gdb.cp/vla-cxx.cc b/gdb/testsuite/gdb.cp/vla-cxx.cc ---- a/gdb/testsuite/gdb.cp/vla-cxx.cc -+++ b/gdb/testsuite/gdb.cp/vla-cxx.cc -@@ -15,6 +15,10 @@ - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -+extern "C" { -+#include -+} -+ - struct container; - - struct element -@@ -40,11 +44,16 @@ int main(int argc, char **argv) - typedef typeof (vla) &vlareftypedef; - vlareftypedef vlaref2 (vla); - container c; -+ typeof (vla) *ptr = NULL; -+ -+ // Before pointer assignment -+ ptr = &vla; - - for (int i = 0; i < z; ++i) - vla[i] = 5 + 2 * i; - - // vlas_filled - vla[0] = 2 * vla[0]; -+ - return vla[2]; - } -diff --git a/gdb/testsuite/gdb.cp/vla-cxx.exp b/gdb/testsuite/gdb.cp/vla-cxx.exp ---- a/gdb/testsuite/gdb.cp/vla-cxx.exp -+++ b/gdb/testsuite/gdb.cp/vla-cxx.exp -@@ -23,6 +23,12 @@ if ![runto_main] { - return -1 - } - -+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] -+gdb_continue_to_breakpoint "Before pointer assignment" -+gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment" -+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment" -+gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment" -+ - gdb_breakpoint [gdb_get_line_number "vlas_filled"] - gdb_continue_to_breakpoint "vlas_filled" - -@@ -33,3 +39,6 @@ gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}" - # bug being tested, it's better not to depend on the exact spelling. - gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}" - gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}" -+gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]" -+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex" -+gdb_test "print *ptr" " = \\{5, 7, 9\\}" -diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/pointers.exp -@@ -0,0 +1,143 @@ -+# Copyright 2016 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+standard_testfile "pointers.f90" -+load_lib fortran.exp -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ -+ {debug f90 quiet}] } { -+ return -1 -+} -+ -+if ![runto_main] { -+ untested "could not run to main" -+ return -1 -+} -+ -+# Depending on the compiler being used, the type names can be printed differently. -+set logical [fortran_logical4] -+set real [fortran_real4] -+set int [fortran_int4] -+set complex [fortran_complex4] -+ -+ -+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] -+gdb_continue_to_breakpoint "Before pointer assignment" -+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) 0x0" "print logp, not associated" -+gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated" -+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) 0x0" "print comp, not associated" -+gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated" -+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) 0x0" "print charp, not associated" -+gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated" -+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) 0x0" "print charap, not associated" -+gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated" -+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" "print intp, not associated" -+gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated" -+set test "print intap, not associated" -+gdb_test_multiple "print intap" $test { -+ -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) \r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re " = \r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) 0x0" "print realp, not associated" -+gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated" -+gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" -+set test "print cyclicp1, not associated" -+gdb_test_multiple "print cyclicp1" $test { -+ -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "= \\( i = -?\\d+, p = \\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+set test "print cyclicp1%p, not associated" -+gdb_test_multiple "print cyclicp1%p" $test { -+ -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) 0x0\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) \r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+ -+gdb_breakpoint [gdb_get_line_number "Before value assignment"] -+gdb_continue_to_breakpoint "Before value assignment" -+gdb_test "print *(twop)%ivla2" "= " -+ -+ -+gdb_breakpoint [gdb_get_line_number "After value assignment"] -+gdb_continue_to_breakpoint "After value assignment" -+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) $hex\( <.*>\)?" -+gdb_test "print *logp" "= \\.TRUE\\." -+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) $hex\( <.*>\)?" -+gdb_test "print *comp" "= \\(1,2\\)" -+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) $hex\( <.*>\)?" -+gdb_test "print *charp" "= 'a'" -+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\( <.*>\)?" -+gdb_test "print *charap" "= 'abc'" -+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) $hex\( <.*>\)?" -+gdb_test "print *intp" "= 10" -+set test_name "print intap, associated" -+gdb_test_multiple "print intap" $test_name { -+ -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+ -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" { -+ gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)" -+ pass $test_name -+ } -+} -+set test_name "print intvlap, associated" -+gdb_test_multiple "print intvlap" $test_name { -+ -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+ -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" { -+ gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)" -+ pass $test_name -+ } -+} -+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) $hex\( <.*>\)?" -+gdb_test "print *realp" "= 3\\.14000\\d+" -+gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two\\)\\) $hex\( <.*>\)?" -+gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)" -+set test_name "print arrayOfPtr(3)%p" -+gdb_test_multiple $test_name $test_name { -+ -re "= \\(PTR TO -> \\( Type two\\)\\) \r\n$gdb_prompt $" { -+ pass $test_name -+ } -+ -re "= \\(PTR TO -> \\( Type two\\)\\) 0x0\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+} -+set test_name "print *(arrayOfPtr(3)%p), associated" -+gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name { -+ -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+ -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" { -+ pass $test_name -+ } -+} -+gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)" -+gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer\\)\\) $hex\( <.*>\)?" -+gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array" -+gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla" -+gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\) \\(\\)\\)\\) $hex " "Print program counter" -diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90 ---- a/gdb/testsuite/gdb.fortran/pointers.f90 -+++ b/gdb/testsuite/gdb.fortran/pointers.f90 -@@ -20,21 +20,34 @@ program pointers - integer, allocatable :: ivla2 (:, :) - end type two - -+ type :: typeWithPointer -+ integer i -+ type(typeWithPointer), pointer:: p -+ end type typeWithPointer -+ -+ type :: twoPtr -+ type (two), pointer :: p -+ end type twoPtr -+ - logical, target :: logv - complex, target :: comv - character, target :: charv - character (len=3), target :: chara - integer, target :: intv - integer, target, dimension (10,2) :: inta -- real, target :: realv -- type(two), target :: twov -+ integer, target, allocatable, dimension (:) :: intvla -+ real, target :: realv -+ type(two), target :: twov -+ type(twoPtr) :: arrayOfPtr (3) -+ type(typeWithPointer), target:: cyclicp1,cyclicp2 - - logical, pointer :: logp - complex, pointer :: comp -- character, pointer :: charp -- character (len=3), pointer :: charap -+ character, pointer:: charp -+ character (len=3), pointer:: charap - integer, pointer :: intp - integer, pointer, dimension (:,:) :: intap -+ integer, pointer, dimension (:) :: intvlap - real, pointer :: realp - type(two), pointer :: twop - -@@ -44,8 +57,14 @@ program pointers - nullify (charap) - nullify (intp) - nullify (intap) -+ nullify (intvlap) - nullify (realp) - nullify (twop) -+ nullify (arrayOfPtr(1)%p) -+ nullify (arrayOfPtr(2)%p) -+ nullify (arrayOfPtr(3)%p) -+ nullify (cyclicp1%p) -+ nullify (cyclicp2%p) - - logp => logv ! Before pointer assignment - comp => comv -@@ -53,8 +72,14 @@ program pointers - charap => chara - intp => intv - intap => inta -+ intvlap => intvla - realp => realv - twop => twov -+ arrayOfPtr(2)%p => twov -+ cyclicp1%i = 1 -+ cyclicp1%p => cyclicp2 -+ cyclicp2%i = 2 -+ cyclicp2%p => cyclicp1 - - logv = associated(logp) ! Before value assignment - comv = cmplx(1,2) -@@ -63,6 +88,10 @@ program pointers - intv = 10 - inta(:,:) = 1 - inta(3,1) = 3 -+ allocate (intvla(10)) -+ intvla(:) = 2 -+ intvla(4) = 4 -+ intvlap => intvla - realv = 3.14 - - allocate (twov%ivla1(3)) -diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp ---- a/gdb/testsuite/gdb.fortran/print_type.exp -+++ b/gdb/testsuite/gdb.fortran/print_type.exp -@@ -1,5 +1,6 @@ - # Copyright 2019-2020 Free Software Foundation, Inc. - # -+ - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by - # the Free Software Foundation; either version 3 of the License, or -@@ -40,7 +41,7 @@ set complex [fortran_complex4] - # matches the string TYPE. - proc check_pointer_type { var_name type } { - gdb_test "ptype ${var_name}" \ -- "type = PTR TO -> \\( ${type} \\)" -+ "type = PTR TO -> \\( ${type}\\)" - } - - gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] -@@ -85,7 +86,8 @@ gdb_test "ptype twop" \ - [multi_line "type = PTR TO -> \\( Type two" \ - " $int, allocatable :: ivla1\\(:\\)" \ - " $int, allocatable :: ivla2\\(:,:\\)" \ -- "End Type two \\)"] -+ "End Type two\\)"] -+ - - gdb_breakpoint [gdb_get_line_number "After value assignment"] - gdb_continue_to_breakpoint "After value assignment" -@@ -97,11 +99,11 @@ gdb_test "ptype intv" "type = $int" - gdb_test "ptype inta" "type = $int \\(10,2\\)" - gdb_test "ptype realv" "type = $real" - --gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)" --gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)" --gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)" --gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)" --gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)" -+gdb_test "ptype logp" "type = PTR TO -> \\( $logical\\)" -+gdb_test "ptype comp" "type = PTR TO -> \\( $complex\\)" -+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1\\)" -+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3\\)" -+gdb_test "ptype intp" "type = PTR TO -> \\( $int\\)" - set test "ptype intap" - gdb_test_multiple $test $test { - -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" { -@@ -111,4 +113,4 @@ gdb_test_multiple $test $test { - pass $test - } - } --gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)" -+gdb_test "ptype realp" "type = PTR TO -> \\( $real\\)" -diff --git a/gdb/testsuite/gdb.fortran/vla-strings.exp b/gdb/testsuite/gdb.fortran/vla-strings.exp -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-strings.exp -@@ -0,0 +1,103 @@ -+# Copyright 2016 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+standard_testfile ".f90" -+ -+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ -+ {debug f90 quiet}] } { -+ return -1 -+} -+ -+# check that all fortran standard datatypes will be -+# handled correctly when using as VLA's -+ -+if ![runto_main] { -+ untested "could not run to main" -+ return -1 -+} -+ -+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"] -+gdb_continue_to_breakpoint "var_char-allocated-1" -+set test "whatis var_char first time" -+gdb_test_multiple "whatis var_char" $test { -+ -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "type = character\\*10\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+set test "ptype var_char first time" -+gdb_test_multiple "ptype var_char" $test { -+ -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "type = character\\*10\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+ -+ -+gdb_test "next" "\\d+.*var_char = 'foo'.*" \ -+ "next to allocation status of var_char" -+gdb_test "print l" " = \\.TRUE\\." "print allocation status first time" -+ -+ -+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"] -+gdb_continue_to_breakpoint "var_char-filled-1" -+set test "print var_char, var_char-filled-1" -+gdb_test_multiple "print var_char" $test { -+ -re "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\r\n$gdb_prompt $" { -+ gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1" -+ pass $test -+ } -+ -re "= 'foo'\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+set test "ptype var_char, var_char-filled-1" -+gdb_test_multiple "ptype var_char" $test { -+ -re "type = PTR TO -> \\( character\\*3\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "type = character\\*3\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)" -+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)" -+ -+ -+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"] -+gdb_continue_to_breakpoint "var_char-filled-2" -+set test "print var_char, var_char-filled-2" -+gdb_test_multiple "print var_char" $test { -+ -re "= \\(PTR TO -> \\( character\\*6\\)\\) $hex\r\n$gdb_prompt $" { -+ gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2" -+ pass $test -+ } -+ -re "= 'foobar'\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -+set test "ptype var_char, var_char-filled-2" -+gdb_test_multiple "ptype var_char" $test { -+ -re "type = PTR TO -> \\( character\\*6\\)\r\n$gdb_prompt $" { -+ pass $test -+ } -+ -re "type = character\\*6\r\n$gdb_prompt $" { -+ pass $test -+ } -+} -diff --git a/gdb/testsuite/gdb.fortran/vla-strings.f90 b/gdb/testsuite/gdb.fortran/vla-strings.f90 -new file mode 100644 ---- /dev/null -+++ b/gdb/testsuite/gdb.fortran/vla-strings.f90 -@@ -0,0 +1,39 @@ -+! Copyright 2016 Free Software Foundation, Inc. -+! -+! This program is free software; you can redistribute it and/or modify -+! it under the terms of the GNU General Public License as published by -+! the Free Software Foundation; either version 3 of the License, or -+! (at your option) any later version. -+! -+! This program is distributed in the hope that it will be useful, -+! but WITHOUT ANY WARRANTY; without even the implied warranty of -+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+! GNU General Public License for more details. -+! -+! You should have received a copy of the GNU General Public License -+! along with this program. If not, see . -+ -+program vla_strings -+ character(len=:), target, allocatable :: var_char -+ character(len=:), pointer :: var_char_p -+ logical :: l -+ -+ allocate(character(len=10) :: var_char) -+ l = allocated(var_char) ! var_char-allocated-1 -+ var_char = 'foo' -+ deallocate(var_char) ! var_char-filled-1 -+ l = allocated(var_char) ! var_char-deallocated -+ allocate(character(len=42) :: var_char) -+ l = allocated(var_char) -+ var_char = 'foobar' -+ var_char = '' ! var_char-filled-2 -+ var_char = 'bar' ! var_char-empty -+ deallocate(var_char) -+ allocate(character(len=21) :: var_char) -+ l = allocated(var_char) ! var_char-allocated-3 -+ var_char = 'johndoe' -+ var_char_p => var_char -+ l = associated(var_char_p) ! var_char_p-associated -+ var_char_p => null() -+ l = associated(var_char_p) ! var_char_p-not-associated -+end program vla_strings -diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp ---- a/gdb/testsuite/gdb.fortran/vla-value.exp -+++ b/gdb/testsuite/gdb.fortran/vla-value.exp -@@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"] - gdb_continue_to_breakpoint "vla1-init" - gdb_test "print vla1" " = " "print non-allocated vla1" - gdb_test "print &vla1" \ -- " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\) \\\)\\\) $hex" \ -+ " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\)\\\)\\\) $hex" \ - "print non-allocated &vla1" - gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \ - "print member in non-allocated vla1 (1)" -@@ -56,7 +56,7 @@ with_timeout_factor 15 { - "step over value assignment of vla1" - } - gdb_test "print &vla1" \ -- " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\) \\\)\\\) $hex" \ -+ " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\)\\\)\\\) $hex" \ - "print allocated &vla1" - gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)" - gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)" -@@ -76,7 +76,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \ - # Try to access values in undefined pointer to VLA (dangling) - gdb_test "print pvla" " = " "print undefined pvla" - gdb_test "print &pvla" \ -- " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\) \\\)\\\) $hex" \ -+ " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \ - "print non-associated &pvla" - gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \ - "print undefined pvla(1,3,8)" -@@ -85,7 +85,7 @@ gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated - gdb_breakpoint [gdb_get_line_number "pvla-associated"] - gdb_continue_to_breakpoint "pvla-associated" - gdb_test "print &pvla" \ -- " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \ -+ " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \ - "print associated &pvla" - gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)" - gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)" -diff --git a/gdb/typeprint.c b/gdb/typeprint.c ---- a/gdb/typeprint.c -+++ b/gdb/typeprint.c -@@ -574,6 +574,25 @@ whatis_exp (const char *exp, int show) - printf_filtered (" */\n"); - } - -+ /* Resolve any dynamic target type, as we might print -+ additional information about the target. -+ For example, in Fortran and C we are printing the dimension of the -+ dynamic array the pointer is pointing to. */ -+ if (TYPE_CODE (type) == TYPE_CODE_PTR -+ && is_dynamic_type (type) == 1) -+ { -+ CORE_ADDR addr; -+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type))) -+ addr = value_address (val); -+ else -+ addr = value_as_address (val); -+ -+ if (addr != 0 -+ && type_not_associated (type) == 0) -+ TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type), -+ NULL, addr); -+ } -+ - LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags); - printf_filtered ("\n"); - } -diff --git a/gdb/valops.c b/gdb/valops.c ---- a/gdb/valops.c -+++ b/gdb/valops.c -@@ -1553,6 +1553,19 @@ value_ind (struct value *arg1) - if (TYPE_CODE (base_type) == TYPE_CODE_PTR) - { - struct type *enc_type; -+ CORE_ADDR addr; -+ -+ if (type_not_associated (base_type)) -+ error (_("Attempt to take contents of a not associated pointer.")); -+ -+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type))) -+ addr = value_address (arg1); -+ else -+ addr = value_as_address (arg1); -+ -+ if (addr != 0) -+ TYPE_TARGET_TYPE (base_type) = -+ resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), NULL, addr); - - /* We may be pointing to something embedded in a larger object. - Get the real type of the enclosing object. */ -@@ -1568,8 +1581,7 @@ value_ind (struct value *arg1) - else - /* Retrieve the enclosing object pointed to. */ - arg2 = value_at_lazy (enc_type, -- (value_as_address (arg1) -- - value_pointed_to_offset (arg1))); -+ (addr - value_pointed_to_offset (arg1))); - - enc_type = value_type (arg2); - return readjust_indirect_value_type (arg2, enc_type, base_type, arg1); -diff --git a/gdb/valprint.c b/gdb/valprint.c ---- a/gdb/valprint.c -+++ b/gdb/valprint.c -@@ -1149,12 +1149,6 @@ value_check_printable (struct value *val, struct ui_file *stream, - return 0; - } - -- if (type_not_associated (value_type (val))) -- { -- val_print_not_associated (stream); -- return 0; -- } -- - if (type_not_allocated (value_type (val))) - { - val_print_not_allocated (stream); diff --git a/gdb-vla-intel-stringbt-fix.patch b/gdb-vla-intel-stringbt-fix.patch index aedc7b1..1a2bbb1 100644 --- a/gdb-vla-intel-stringbt-fix.patch +++ b/gdb-vla-intel-stringbt-fix.patch @@ -27,10 +27,10 @@ cannot reproduce it. Thanks, Jan -diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c ---- a/gdb/dwarf2loc.c -+++ b/gdb/dwarf2loc.c -@@ -2154,6 +2154,20 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, +diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c +--- a/gdb/dwarf2/loc.c ++++ b/gdb/dwarf2/loc.c +@@ -2249,6 +2249,20 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, ctx.per_cu = per_cu; ctx.obj_address = 0; @@ -50,7 +50,7 @@ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c + scoped_value_mark free_values; - ctx.gdbarch = get_objfile_arch (objfile); + ctx.gdbarch = per_objfile->objfile->arch (); diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 new file mode 100644 --- /dev/null diff --git a/insight-10.0-fix-a-prototype.patch b/insight-10.0-fix-a-prototype.patch deleted file mode 100644 index 56e3dd4..0000000 --- a/insight-10.0-fix-a-prototype.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 48bf56bba4dc0f1a4f3ea5dd91918f99477779bd Mon Sep 17 00:00:00 2001 -From: Patrick Monnerat -Date: Wed, 5 Feb 2020 10:39:26 +0100 -Subject: [PATCH] Fix a prototype. - ---- - gdbtk/generic/gdbtk.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/gdb/gdbtk/generic/gdbtk.h b/gdb/gdbtk/generic/gdbtk.h -index 1f1d076..e51ad87 100644 ---- a/gdb/gdbtk/generic/gdbtk.h -+++ b/gdb/gdbtk/generic/gdbtk.h -@@ -1,5 +1,5 @@ - /* Tcl/Tk interface routines header file. -- Copyright (C) 1994-2019 Free Software Foundation, Inc. -+ Copyright (C) 1994-2020 Free Software Foundation, Inc. - - Written by Stu Grossman of Cygnus Support. - -@@ -163,7 +163,7 @@ extern void gdbtk_start_timer (void); - extern long gdbtk_getpid(void); - extern void gdbtk_ignorable_warning (const char *, const char *); - extern int x_event (int); --extern int gdbtk_two_elem_cmd (char *, const char *); -+extern int gdbtk_two_elem_cmd (const char *, const char *); - extern int target_is_native (struct target_ops *t); - extern int gdbtk_test (char *); - extern struct ui_file *gdbtk_fileopen (void); --- -2.24.1 - diff --git a/insight-10.0-readline-system.patch b/insight-10.0-readline-system.patch deleted file mode 100644 index 6c9ed3b..0000000 --- a/insight-10.0-readline-system.patch +++ /dev/null @@ -1,72 +0,0 @@ -diff -Naurp insight-10.0.50.20200110.orig/gdb/configure.ac insight-10.0.50.20200110.new/gdb/configure.ac ---- insight-10.0.50.20200110.orig/gdb/configure.ac 2020-02-07 00:46:03.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/configure.ac 2020-02-07 02:41:09.909685184 +0100 -@@ -593,16 +593,19 @@ if test "$with_system_readline" = yes; t - - READLINE=-lreadline - READLINE_DEPS= -+ READLINE_SRC='$(includedir)/readline' - READLINE_CFLAGS= - READLINE_TEXI_INCFLAG= - else - READLINE='$(READLINE_DIR)/libreadline.a' - READLINE_DEPS='$(READLINE)' -+ READLINE_SRC='$(srcdir)/../readline' - READLINE_CFLAGS='-I$(READLINE_SRC)/..' - READLINE_TEXI_INCFLAG='-I $(READLINE_DIR)' - fi - AC_SUBST(READLINE) - AC_SUBST(READLINE_DEPS) -+AC_SUBST(READLINE_SRC) - AC_SUBST(READLINE_CFLAGS) - AC_SUBST(READLINE_TEXI_INCFLAG) - -diff -Naurp insight-10.0.50.20200110.orig/gdb/doc/gdb.texinfo insight-10.0.50.20200110.new/gdb/doc/gdb.texinfo ---- insight-10.0.50.20200110.orig/gdb/doc/gdb.texinfo 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/doc/gdb.texinfo 2020-02-07 02:41:09.917685263 +0100 -@@ -37447,9 +37447,6 @@ source for the @samp{-liberty} free soft - - @item gdb-@value{GDBVN}/opcodes - source for the library of opcode tables and disassemblers -- --@item gdb-@value{GDBVN}/readline --source for the @sc{gnu} command-line interface - @end table - - There may be other subdirectories as well. -@@ -37491,7 +37488,7 @@ source tree, the @file{gdb-@var{version- - that subdirectory. That is usually not what you want. In particular, - if you run the first @file{configure} from the @file{gdb} subdirectory - of the @file{gdb-@var{version-number}} directory, you will omit the --configuration of @file{bfd}, @file{readline}, and other sibling -+configuration of @file{bfd}, and other sibling - directories of the @file{gdb} subdirectory. This leads to build errors - about missing include files such as @file{bfd/bfd.h}. - -diff -Naurp insight-10.0.50.20200110.orig/gdb/doc/Makefile.in insight-10.0.50.20200110.new/gdb/doc/Makefile.in ---- insight-10.0.50.20200110.orig/gdb/doc/Makefile.in 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/doc/Makefile.in 2020-02-07 02:41:09.917685263 +0100 -@@ -128,9 +128,7 @@ DVIPS = dvips - GDB_DOC_SOURCE_INCLUDES = \ - $(srcdir)/fdl.texi \ - $(srcdir)/gpl.texi \ -- $(srcdir)/agentexpr.texi \ -- $(READLINE_DIR)/rluser.texi \ -- $(READLINE_DIR)/hsuser.texi -+ $(srcdir)/agentexpr.texi - GDB_DOC_BUILD_INCLUDES = \ - gdb-cfg.texi \ - GDBvn.texi -diff -Naurp insight-10.0.50.20200110.orig/gdb/Makefile.in insight-10.0.50.20200110.new/gdb/Makefile.in ---- insight-10.0.50.20200110.orig/gdb/Makefile.in 2020-02-07 02:38:51.532319771 +0100 -+++ insight-10.0.50.20200110.new/gdb/Makefile.in 2020-02-07 02:43:33.887108619 +0100 -@@ -175,8 +175,7 @@ LIBDECNUMBER_SRC = $(srcdir)/$(LIBDECNUM - LIBDECNUMBER_CFLAGS = -I$(LIBDECNUMBER_DIR) -I$(LIBDECNUMBER_SRC) - - # Where is the READLINE library? Typically in ../readline/readline. --READLINE_DIR = ../readline/readline --READLINE_SRC = $(srcdir)/$(READLINE_DIR) -+READLINE_SRC = @READLINE_SRC@ - READLINE = @READLINE@ - READLINE_DEPS = @READLINE_DEPS@ - READLINE_CFLAGS = @READLINE_CFLAGS@ diff --git a/insight-10.0.50-gcc10.patch b/insight-10.0.50-gcc10.patch deleted file mode 100644 index 93240de..0000000 --- a/insight-10.0.50-gcc10.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Naurp insight-10.0.50.20200110.orig/bfd/elf-bfd.h insight-10.0.50.20200110.new/bfd/elf-bfd.h ---- insight-10.0.50.20200110.orig/bfd/elf-bfd.h 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/bfd/elf-bfd.h 2020-04-06 15:28:26.761744216 +0200 -@@ -1937,7 +1937,7 @@ struct elf_obj_tdata - struct sdt_note *sdt_note_head; - - Elf_Internal_Shdr **group_sect_ptr; -- int num_group; -+ unsigned int num_group; - - /* Index into group_sect_ptr, updated by setup_group when finding a - section's group. Used to optimize subsequent group searches. */ diff --git a/insight-10.0.50-python39-2.patch b/insight-10.0.50-python39-2.patch deleted file mode 100644 index d5df2dd..0000000 --- a/insight-10.0.50-python39-2.patch +++ /dev/null @@ -1,94 +0,0 @@ -diff -Naurp insight-10.0.50.20200110.orig/gdb/python/python.c insight-10.0.50.20200110.new/gdb/python/python.c ---- insight-10.0.50.20200110.orig/gdb/python/python.c 2020-08-08 14:46:37.009425031 +0200 -+++ insight-10.0.50.20200110.new/gdb/python/python.c 2020-08-08 14:56:18.260614503 +0200 -@@ -234,6 +234,30 @@ gdbpy_enter::~gdbpy_enter () - PyGILState_Release (m_state); - } - -+/* A helper class to save and restore the GIL, but without touching -+ the other globals that are handled by gdbpy_enter. */ -+ -+class gdbpy_gil -+{ -+public: -+ -+ gdbpy_gil () -+ : m_state (PyGILState_Ensure ()) -+ { -+ } -+ -+ ~gdbpy_gil () -+ { -+ PyGILState_Release (m_state); -+ } -+ -+ DISABLE_COPY_AND_ASSIGN (gdbpy_gil); -+ -+private: -+ -+ PyGILState_STATE m_state; -+}; -+ - /* Set the quit flag. */ - - static void -@@ -247,6 +271,10 @@ gdbpy_set_quit_flag (const struct extens - static int - gdbpy_check_quit_flag (const struct extension_language_defn *extlang) - { -+ if (!gdb_python_initialized) -+ return 0; -+ -+ gdbpy_gil gil; - return PyOS_InterruptOccurred (); - } - -@@ -924,30 +952,6 @@ gdbpy_source_script (const struct extens - - /* Posting and handling events. */ - --/* A helper class to save and restore the GIL, but without touching -- the other globals that are handled by gdbpy_enter. */ -- --class gdbpy_gil --{ --public: -- -- gdbpy_gil () -- : m_state (PyGILState_Ensure ()) -- { -- } -- -- ~gdbpy_gil () -- { -- PyGILState_Release (m_state); -- } -- -- DISABLE_COPY_AND_ASSIGN (gdbpy_gil); -- --private: -- -- PyGILState_STATE m_state; --}; -- - /* A single event. */ - struct gdbpy_event - { -@@ -1548,6 +1552,7 @@ finalize_python (void *ignore) - - Py_Finalize (); - -+ gdb_python_initialized = false; - restore_active_ext_lang (previous_active); - } - -@@ -1720,8 +1725,7 @@ do_start_initialization () - return false; - - /* Release the GIL while gdb runs. */ -- PyThreadState_Swap (NULL); -- PyEval_ReleaseLock (); -+ PyEval_SaveThread (); - - make_final_cleanup (finalize_python, NULL); - diff --git a/insight-10.0.50-python39.patch b/insight-10.0.50-python39.patch deleted file mode 100644 index c4821cb..0000000 --- a/insight-10.0.50-python39.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff -Naurp insight-10.0.50.20200110.orig/gdb/python/python.c insight-10.0.50.20200110.new/gdb/python/python.c ---- insight-10.0.50.20200110.orig/gdb/python/python.c 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/python/python.c 2020-05-05 16:52:16.575022701 +0200 -@@ -1618,7 +1618,12 @@ do_start_initialization () - #endif - - Py_Initialize (); -+#if PY_VERSION_HEX < 0x03090000 -+ /* PyEval_InitThreads became deprecated in Python 3.9 and will -+ be removed in Python 3.11. Prior to Python 3.7, this call was -+ required to initialize the GIL. */ - PyEval_InitThreads (); -+#endif - - #ifdef IS_PY3K - gdb_module = PyImport_ImportModule ("_gdb"); diff --git a/insight-11.0-gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch b/insight-11.0-gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch new file mode 100644 index 0000000..0785cf6 --- /dev/null +++ b/insight-11.0-gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch @@ -0,0 +1,264 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Jan Kratochvil +Date: Fri, 27 Oct 2017 21:07:50 +0200 +Subject: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch + +;; Support TLS symbols (+`errno' suggestion if no pthread is found) (BZ 185337). +;;=push+jan: It should be replaced by Infinity project. + +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185337 + +2008-02-24 Jan Kratochvil + + Port to GDB-6.8pre. + +currently for trivial nonthreaded helloworld with no debug info up to -ggdb2 you +will get: + (gdb) p errno + [some error] + +* with -ggdb2 and less "errno" in fact does not exist anywhere as it was + compiled to "(*__errno_location ())" and the macro definition is not present. + Unfortunately gdb will find the TLS symbol and it will try to access it but + as the program has been compiled without -lpthread the TLS base register + (%gs on i386) is not setup and it will result in: + Cannot access memory at address 0x8 + +Attached suggestion patch how to deal with the most common "errno" symbol +for the most common under-ggdb3 compiled programs. + +Original patch hooked into target_translate_tls_address. But its inferior +call invalidates `struct frame *' in the callers - RH BZ 690908. + +https://bugzilla.redhat.com/show_bug.cgi?id=1166549 + +2007-11-03 Jan Kratochvil + + * ./gdb/dwarf2read.c (read_partial_die, dwarf2_linkage_name): Prefer + DW_AT_MIPS_linkage_name over DW_AT_name now only for non-C. + +glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug: + <81a2> DW_AT_name : (indirect string, offset: 0x280e): __errno_location + <81a8> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2808): *__GI___errno_location + +diff --git a/gdb/printcmd.c b/gdb/printcmd.c +--- a/gdb/printcmd.c ++++ b/gdb/printcmd.c +@@ -1210,6 +1210,10 @@ print_command_1 (const char *args, int voidprint) + + if (exp != nullptr && *exp) + { ++ /* '*((int *(*) (void)) __errno_location) ()' is incompatible with ++ function descriptors. */ ++ if (target_has_execution () && strcmp (exp, "errno") == 0) ++ exp = "*(*(int *(*)(void)) __errno_location) ()"; + expression_up expr = parse_expression (exp); + val = evaluate_expression (expr.get ()); + } +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-errno.c +@@ -0,0 +1,28 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2005, 2007 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@prep.ai.mit.edu */ ++ ++#include ++ ++int main() ++{ ++ errno = 42; ++ ++ return 0; /* breakpoint */ ++} +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.exp b/gdb/testsuite/gdb.dwarf2/dw2-errno.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-errno.exp +@@ -0,0 +1,60 @@ ++# Copyright 2007 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile dw2-errno ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++ ++proc prep {} { ++ global srcdir subdir binfile ++ gdb_exit ++ gdb_start ++ gdb_reinitialize_dir $srcdir/$subdir ++ gdb_load ${binfile} ++ ++ runto_main ++ ++ gdb_breakpoint [gdb_get_line_number "breakpoint"] ++ gdb_continue_to_breakpoint "breakpoint" ++} ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++prep ++gdb_test "print errno" ".* = 42" "errno with macros=N threads=N" ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++prep ++gdb_test "print errno" ".* = 42" "errno with macros=Y threads=N" ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g2"] != "" } { ++ return -1 ++} ++prep ++gdb_test "print errno" ".* = 42" "errno with macros=N threads=Y" ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "additional_flags=-g3"] != "" } { ++ return -1 ++} ++prep ++gdb_test "print errno" ".* = 42" "errno with macros=Y threads=Y" ++ ++# TODO: Test the error on resolving ERRNO with only libc loaded. ++# Just how to find the current libc filename? +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno2.c b/gdb/testsuite/gdb.dwarf2/dw2-errno2.c +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-errno2.c +@@ -0,0 +1,28 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2005, 2007 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++ ++ Please email any bugs, comments, and/or additions to this file to: ++ bug-gdb@prep.ai.mit.edu */ ++ ++#include ++ ++int main() ++{ ++ errno = 42; ++ ++ return 0; /* breakpoint */ ++} +diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp b/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.dwarf2/dw2-errno2.exp +@@ -0,0 +1,71 @@ ++# Copyright 2007 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++set testfile dw2-errno2 ++set srcfile ${testfile}.c ++set binfile [standard_output_file ${testfile}] ++ ++proc prep { message {do_xfail 0} } { with_test_prefix $message { ++ global srcdir subdir binfile variant ++ gdb_exit ++ gdb_start ++ gdb_reinitialize_dir $srcdir/$subdir ++ gdb_load ${binfile}${variant} ++ ++ runto_main ++ ++ gdb_breakpoint [gdb_get_line_number "breakpoint"] ++ gdb_continue_to_breakpoint "breakpoint" ++ ++ gdb_test "gcore ${binfile}${variant}.core" "\r\nSaved corefile .*" "gcore $variant" ++ ++ gdb_test "print errno" ".* = 42" ++ ++ gdb_test "kill" ".*" "kill" {Kill the program being debugged\? \(y or n\) } "y" ++ gdb_test "core-file ${binfile}${variant}.core" "\r\nCore was generated by .*" "core-file" ++ if $do_xfail { ++ setup_xfail "*-*-*" ++ } ++ gdb_test "print (int) errno" ".* = 42" "print errno for core" ++}} ++ ++set variant g2thrN ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g2"] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++prep "macros=N threads=N" 1 ++ ++set variant g3thrN ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g3"] != "" } { ++ untested "Couldn't compile test program" ++ return -1 ++} ++prep "macros=Y threads=N" 1 ++ ++set variant g2thrY ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g2"] != "" } { ++ return -1 ++} ++prep "macros=N threads=Y" ++ ++set variant g3thrY ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}${variant}" executable "additional_flags=-g3"] != "" } { ++ return -1 ++} ++prep "macros=Y threads=Y" 1 ++ ++# TODO: Test the error on resolving ERRNO with only libc loaded. ++# Just how to find the current libc filename? diff --git a/insight-11.0-gdb-6.6-buildid-locate-core-as-arg.patch b/insight-11.0-gdb-6.6-buildid-locate-core-as-arg.patch new file mode 100644 index 0000000..a48d10d --- /dev/null +++ b/insight-11.0-gdb-6.6-buildid-locate-core-as-arg.patch @@ -0,0 +1,134 @@ +diff -Naurp insight-11.0.50.20201205.orig/gdb/exec.c insight-11.0.50.20201205.new/gdb/exec.c +--- insight-11.0.50.20201205.orig/gdb/exec.c 2020-12-14 17:14:15.773024942 +0100 ++++ insight-11.0.50.20201205.new/gdb/exec.c 2020-12-14 17:41:07.965466637 +0100 +@@ -18,6 +18,8 @@ + along with this program. If not, see . */ + + #include "defs.h" ++#include "arch-utils.h" ++#include "exceptions.h" + #include "frame.h" + #include "inferior.h" + #include "target.h" +@@ -473,12 +475,28 @@ exec_file_attach (const char *filename, + if (!bfd_check_format_matches (current_program_space->exec_bfd (), + bfd_object, &matching)) + { ++ int is_core; ++ ++ /* If the user accidentally did "gdb core", print a useful ++ error message. Check it only after bfd_object has been checked as ++ a valid executable may get recognized for example also as ++ "trad-core". */ ++ is_core = bfd_check_format (current_program_space->exec_bfd (), ++ bfd_core); ++ + /* Make sure to close exec_bfd, or else "run" might try to use + it. */ + current_program_space->exec_close (); +- error (_("\"%ps\": not in executable format: %s"), +- styled_string (file_name_style.style (), scratch_pathname), +- gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); ++ ++ if (is_core != 0) ++ throw_error (IS_CORE_ERROR, ++ _("\"%s\" is a core file.\n" ++ "Please specify an executable to debug."), ++ scratch_pathname); ++ else ++ error (_("\"%ps\": not in executable format: %s"), ++ styled_string (file_name_style.style (), scratch_pathname), ++ gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); + } + + target_section_table sections +diff -Naurp insight-11.0.50.20201205.orig/gdb/main.c insight-11.0.50.20201205.new/gdb/main.c +--- insight-11.0.50.20201205.orig/gdb/main.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/main.c 2020-12-14 17:45:54.096207219 +0100 +@@ -519,6 +519,34 @@ struct cmdarg + (matching CMD_TYPE). Update the value in *RET if and scripts or + commands are executed. */ + ++/* Call exec_file_attach. If it detected FILENAME is a core file call ++ core_file_command. Print the original exec_file_attach error only if ++ core_file_command failed to find a matching executable. */ ++ ++static void ++exec_or_core_file_attach (const char *filename, int from_tty) ++{ ++ gdb_assert (current_program_space->exec_bfd () == NULL); ++ ++ try ++ { ++ exec_file_attach (filename, from_tty); ++ } ++ catch (gdb_exception_error &e) ++ { ++ if (e.error == IS_CORE_ERROR) ++ { ++ core_file_command ((char *) filename, from_tty); ++ ++ /* Iff the core file found its executable suppress the error message ++ from exec_file_attach. */ ++ if (current_program_space->exec_bfd () != NULL) ++ return; ++ } ++ throw_exception (std::move (e)); ++ } ++} ++ + static void + execute_cmdargs (const std::vector *cmdarg_vec, + cmdarg_kind file_type, cmdarg_kind cmd_type, +@@ -970,6 +998,8 @@ captured_main_1 (struct captured_main_ar + { + symarg = argv[optind]; + execarg = argv[optind]; ++ if (optind + 1 == argc && corearg == NULL) ++ corearg = argv[optind]; + optind++; + } + +@@ -1110,12 +1140,25 @@ captured_main_1 (struct captured_main_ar + && symarg != NULL + && strcmp (execarg, symarg) == 0) + { ++ catch_command_errors_const_ftype *func; ++ ++ /* Call exec_or_core_file_attach only if the file was specified as ++ a command line argument (and not an a command line option). */ ++ if (corearg != NULL && strcmp (corearg, execarg) == 0) ++ { ++ func = exec_or_core_file_attach; ++ corearg = NULL; ++ } ++ else ++ func = exec_file_attach; ++ + /* The exec file and the symbol-file are the same. If we can't + open it, better only print one error message. +- catch_command_errors returns non-zero on success! */ +- ret = catch_command_errors (exec_file_attach, execarg, +- !batch_flag); +- if (ret != 0) ++ catch_command_errors returns non-zero on success! ++ Do not load EXECARG as a symbol file if it has been already processed ++ as a core file. */ ++ ret = catch_command_errors (func, execarg, !batch_flag); ++ if (ret != 0 && core_bfd == NULL) + ret = catch_command_errors (symbol_file_add_main_adapter, + symarg, !batch_flag); + } +diff -Naurp insight-11.0.50.20201205.orig/gdbsupport/common-exceptions.h insight-11.0.50.20201205.new/gdbsupport/common-exceptions.h +--- insight-11.0.50.20201205.orig/gdbsupport/common-exceptions.h 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdbsupport/common-exceptions.h 2020-12-14 17:14:52.424375992 +0100 +@@ -106,6 +106,9 @@ enum errors { + "_ERROR" is appended to the name. */ + MAX_COMPLETIONS_REACHED_ERROR, + ++ /* Attempt to load a core file as executable. */ ++ IS_CORE_ERROR, ++ + /* Add more errors here. */ + NR_ERRORS + }; diff --git a/insight-11.0-gdb-6.6-buildid-locate-rpm.patch b/insight-11.0-gdb-6.6-buildid-locate-rpm.patch new file mode 100644 index 0000000..7bca696 --- /dev/null +++ b/insight-11.0-gdb-6.6-buildid-locate-rpm.patch @@ -0,0 +1,1492 @@ +diff -Naurp insight-11.0.50.20201205.orig/gdb/aclocal.m4 insight-11.0.50.20201205.new/gdb/aclocal.m4 +--- insight-11.0.50.20201205.orig/gdb/aclocal.m4 2020-12-05 17:05:33.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/aclocal.m4 2020-12-14 17:09:07.892076038 +0100 +@@ -11,7 +11,223 @@ + # even the implied warranty of MERCHANTABILITY or FITNESS FOR A + # PARTICULAR PURPOSE. + ++# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- ++# serial 1 (pkg-config-0.24) ++# ++# Copyright © 2004 Scott James Remnant . ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# ++# As a special exception to the GNU General Public License, if you ++# distribute this file as part of a program that contains a ++# configuration script generated by Autoconf, you may include it under ++# the same distribution terms that you use for the rest of that program. ++ ++# PKG_PROG_PKG_CONFIG([MIN-VERSION]) ++# ---------------------------------- ++AC_DEFUN([PKG_PROG_PKG_CONFIG], ++[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) ++m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) ++m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) ++AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) ++AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) ++AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) ++ ++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then ++ AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) ++fi ++if test -n "$PKG_CONFIG"; then ++ _pkg_min_version=m4_default([$1], [0.9.0]) ++ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) ++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then ++ AC_MSG_RESULT([yes]) ++ else ++ AC_MSG_RESULT([no]) ++ PKG_CONFIG="" ++ fi ++fi[]dnl ++])# PKG_PROG_PKG_CONFIG ++ ++# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) ++# ++# Check to see whether a particular set of modules exists. Similar ++# to PKG_CHECK_MODULES(), but does not set variables or print errors. ++# ++# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) ++# only at the first occurence in configure.ac, so if the first place ++# it's called might be skipped (such as if it is within an "if", you ++# have to call PKG_CHECK_EXISTS manually ++# -------------------------------------------------------------- ++AC_DEFUN([PKG_CHECK_EXISTS], ++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl ++if test -n "$PKG_CONFIG" && \ ++ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then ++ m4_default([$2], [:]) ++m4_ifvaln([$3], [else ++ $3])dnl ++fi]) ++ ++# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) ++# --------------------------------------------- ++m4_define([_PKG_CONFIG], ++[if test -n "$$1"; then ++ pkg_cv_[]$1="$$1" ++ elif test -n "$PKG_CONFIG"; then ++ PKG_CHECK_EXISTS([$3], ++ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ], ++ [pkg_failed=yes]) ++ else ++ pkg_failed=untried ++fi[]dnl ++])# _PKG_CONFIG ++ ++# _PKG_SHORT_ERRORS_SUPPORTED ++# ----------------------------- ++AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], ++[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes ++else ++ _pkg_short_errors_supported=no ++fi[]dnl ++])# _PKG_SHORT_ERRORS_SUPPORTED ++ ++ ++# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], ++# [ACTION-IF-NOT-FOUND]) ++# ++# ++# Note that if there is a possibility the first call to ++# PKG_CHECK_MODULES might not happen, you should be sure to include an ++# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac ++# ++# ++# -------------------------------------------------------------- ++AC_DEFUN([PKG_CHECK_MODULES], ++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl ++AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl ++AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl ++ ++pkg_failed=no ++AC_MSG_CHECKING([for $1]) ++ ++_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) ++_PKG_CONFIG([$1][_LIBS], [libs], [$2]) ++ ++m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS ++and $1[]_LIBS to avoid the need to call pkg-config. ++See the pkg-config man page for more details.]) ++ ++if test $pkg_failed = yes; then ++ AC_MSG_RESULT([no]) ++ _PKG_SHORT_ERRORS_SUPPORTED ++ if test $_pkg_short_errors_supported = yes; then ++ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` ++ else ++ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD ++ ++ m4_default([$4], [AC_MSG_ERROR( ++[Package requirements ($2) were not met: ++ ++$$1_PKG_ERRORS ++ ++Consider adjusting the PKG_CONFIG_PATH environment variable if you ++installed software in a non-standard prefix. ++ ++_PKG_TEXT])[]dnl ++ ]) ++elif test $pkg_failed = untried; then ++ AC_MSG_RESULT([no]) ++ m4_default([$4], [AC_MSG_FAILURE( ++[The pkg-config script could not be found or is too old. Make sure it ++is in your PATH or set the PKG_CONFIG environment variable to the full ++path to pkg-config. ++ ++_PKG_TEXT ++ ++To get pkg-config, see .])[]dnl ++ ]) ++else ++ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS ++ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS ++ AC_MSG_RESULT([yes]) ++ $3 ++fi[]dnl ++])# PKG_CHECK_MODULES ++ ++ ++# PKG_INSTALLDIR(DIRECTORY) ++# ------------------------- ++# Substitutes the variable pkgconfigdir as the location where a module ++# should install pkg-config .pc files. By default the directory is ++# $libdir/pkgconfig, but the default can be changed by passing ++# DIRECTORY. The user can override through the --with-pkgconfigdir ++# parameter. ++AC_DEFUN([PKG_INSTALLDIR], ++[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) ++m4_pushdef([pkg_description], ++ [pkg-config installation directory @<:@]pkg_default[@:>@]) ++AC_ARG_WITH([pkgconfigdir], ++ [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, ++ [with_pkgconfigdir=]pkg_default) ++AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) ++m4_popdef([pkg_default]) ++m4_popdef([pkg_description]) ++]) dnl PKG_INSTALLDIR ++ ++ ++# PKG_NOARCH_INSTALLDIR(DIRECTORY) ++# ------------------------- ++# Substitutes the variable noarch_pkgconfigdir as the location where a ++# module should install arch-independent pkg-config .pc files. By ++# default the directory is $datadir/pkgconfig, but the default can be ++# changed by passing DIRECTORY. The user can override through the ++# --with-noarch-pkgconfigdir parameter. ++AC_DEFUN([PKG_NOARCH_INSTALLDIR], ++[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) ++m4_pushdef([pkg_description], ++ [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) ++AC_ARG_WITH([noarch-pkgconfigdir], ++ [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, ++ [with_noarch_pkgconfigdir=]pkg_default) ++AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) ++m4_popdef([pkg_default]) ++m4_popdef([pkg_description]) ++]) dnl PKG_NOARCH_INSTALLDIR ++ ++ ++# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, ++# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) ++# ------------------------------------------- ++# Retrieves the value of the pkg-config variable for the given module. ++AC_DEFUN([PKG_CHECK_VAR], ++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl ++AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl ++ ++_PKG_CONFIG([$1], [variable="][$3]["], [$2]) ++AS_VAR_COPY([$1], [pkg_cv_][$1]) ++ ++AS_VAR_IF([$1], [""], [$5], [$4])dnl ++])# PKG_CHECK_VAR ++ + m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) ++ + # AM_AUX_DIR_EXPAND -*- Autoconf -*- + + # Copyright (C) 2001-2020 Free Software Foundation, Inc. +diff -Naurp insight-11.0.50.20201205.orig/gdb/build-id.c insight-11.0.50.20201205.new/gdb/build-id.c +--- insight-11.0.50.20201205.orig/gdb/build-id.c 2020-12-14 17:07:59.795423803 +0100 ++++ insight-11.0.50.20201205.new/gdb/build-id.c 2020-12-14 17:09:07.892076038 +0100 +@@ -33,6 +33,7 @@ + #include "gdb_bfd.h" + #include "gdbcmd.h" + #include "gdbcore.h" ++#include "inferior.h" + #include "objfiles.h" + #include "observable.h" + #include "symfile.h" +@@ -697,8 +698,374 @@ build_id_to_filename (const struct bfd_b + return result; + } + ++#ifdef HAVE_LIBRPM ++ ++#include ++#include ++#include ++#include ++#ifdef DLOPEN_LIBRPM ++#include ++#endif ++ ++/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files ++ and avoid their duplicities during a single inferior run. */ ++ ++static struct htab *missing_rpm_hash; ++ ++/* This MISSING_RPM_LIST tracker is used to collect and print as a single line ++ all the rpms right before the nearest GDB prompt. It gets cleared after ++ each such print (it is questionable if we should clear it after the print). ++ */ ++ ++struct missing_rpm ++ { ++ struct missing_rpm *next; ++ char rpm[1]; ++ }; ++static struct missing_rpm *missing_rpm_list; ++static int missing_rpm_list_entries; ++ ++/* Returns the count of newly added rpms. */ ++ ++static int ++missing_rpm_enlist (const char *filename) ++{ ++ static int rpm_init_done = 0; ++ rpmts ts; ++ rpmdbMatchIterator mi; ++ int count = 0; ++ ++#ifdef DLOPEN_LIBRPM ++ /* Duplicate here the declarations to verify they match. The same sanity ++ check is present also in `configure.ac'. */ ++ extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); ++ static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg); ++ extern int rpmReadConfigFiles(const char * file, const char * target); ++ static int (*rpmReadConfigFiles_p) (const char * file, const char * target); ++ extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); ++ static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi); ++ extern Header rpmdbNextIterator(rpmdbMatchIterator mi); ++ static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi); ++ extern rpmts rpmtsCreate(void); ++ static rpmts (*rpmtsCreate_p) (void); ++ extern rpmts rpmtsFree(rpmts ts); ++ static rpmts (*rpmtsFree_p) (rpmts ts); ++ extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, ++ const void * keyp, size_t keylen); ++ static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts, ++ rpmTag rpmtag, ++ const void *keyp, ++ size_t keylen); ++#else /* !DLOPEN_LIBRPM */ ++# define headerFormat_p headerFormat ++# define rpmReadConfigFiles_p rpmReadConfigFiles ++# define rpmdbFreeIterator_p rpmdbFreeIterator ++# define rpmdbNextIterator_p rpmdbNextIterator ++# define rpmtsCreate_p rpmtsCreate ++# define rpmtsFree_p rpmtsFree ++# define rpmtsInitIterator_p rpmtsInitIterator ++#endif /* !DLOPEN_LIBRPM */ ++ ++ gdb_assert (filename != NULL); ++ ++ if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0) ++ return 0; ++ ++ if (is_target_filename (filename)) ++ return 0; ++ ++ if (filename[0] != '/') ++ { ++ warning (_("Ignoring non-absolute filename: <%s>"), filename); ++ return 0; ++ } ++ ++ if (!rpm_init_done) ++ { ++ static int init_tried; ++ ++ /* Already failed the initialization before? */ ++ if (init_tried) ++ return 0; ++ init_tried = 1; ++ ++#ifdef DLOPEN_LIBRPM ++ { ++ void *h; ++ ++ h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY); ++ if (!h) ++ { ++ warning (_("Unable to open \"%s\" (%s), " ++ "missing debuginfos notifications will not be displayed"), ++ DLOPEN_LIBRPM, dlerror ()); ++ return 0; ++ } ++ ++ if (!((headerFormat_p = (char *(*) (Header h, const char * fmt, errmsg_t *errmsg)) dlsym (h, "headerFormat")) ++ && (rpmReadConfigFiles_p = (int (*) (const char * file, const char * target)) dlsym (h, "rpmReadConfigFiles")) ++ && (rpmdbFreeIterator_p = (rpmdbMatchIterator (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbFreeIterator")) ++ && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator")) ++ && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate")) ++ && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree")) ++ && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator")))) ++ { ++ warning (_("Opened library \"%s\" is incompatible (%s), " ++ "missing debuginfos notifications will not be displayed"), ++ DLOPEN_LIBRPM, dlerror ()); ++ if (dlclose (h)) ++ warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM, ++ dlerror ()); ++ return 0; ++ } ++ } ++#endif /* DLOPEN_LIBRPM */ ++ ++ if (rpmReadConfigFiles_p (NULL, NULL) != 0) ++ { ++ warning (_("Error reading the rpm configuration files")); ++ return 0; ++ } ++ ++ rpm_init_done = 1; ++ } ++ ++ ts = rpmtsCreate_p (); ++ ++ mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0); ++ if (mi != NULL) ++ { ++ for (;;) ++ { ++ Header h; ++ char *debuginfo, **slot, *s, *s2; ++ errmsg_t err; ++ size_t srcrpmlen = sizeof (".src.rpm") - 1; ++ size_t debuginfolen = sizeof ("-debuginfo") - 1; ++ rpmdbMatchIterator mi_debuginfo; ++ ++ h = rpmdbNextIterator_p (mi); ++ if (h == NULL) ++ break; ++ ++ /* Verify the debuginfo file is not already installed. */ ++ ++ debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}", ++ &err); ++ if (!debuginfo) ++ { ++ warning (_("Error querying the rpm file `%s': %s"), filename, ++ err); ++ continue; ++ } ++ /* s = `.src.rpm-debuginfo.%{arch}' */ ++ s = strrchr (debuginfo, '-') - srcrpmlen; ++ s2 = NULL; ++ if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0) ++ { ++ /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */ ++ s2 = (char *) memrchr (debuginfo, '-', s - debuginfo); ++ } ++ if (s2) ++ { ++ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */ ++ s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo); ++ } ++ if (!s2) ++ { ++ warning (_("Error querying the rpm file `%s': %s"), filename, ++ debuginfo); ++ xfree (debuginfo); ++ continue; ++ } ++ /* s = `.src.rpm-debuginfo.%{arch}' */ ++ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */ ++ memmove (s2 + debuginfolen, s2, s - s2); ++ memcpy (s2, "-debuginfo", debuginfolen); ++ /* s = `XXXX.%{arch}' */ ++ /* strlen ("XXXX") == srcrpmlen + debuginfolen */ ++ /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */ ++ /* strlen ("XX") == srcrpmlen */ ++ memmove (s + debuginfolen, s + srcrpmlen + debuginfolen, ++ strlen (s + srcrpmlen + debuginfolen) + 1); ++ /* s = `-debuginfo-%{version}-%{release}.%{arch}' */ ++ ++ /* RPMDBI_PACKAGES requires keylen == sizeof (int). */ ++ /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */ ++ mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0); ++ xfree (debuginfo); ++ if (mi_debuginfo) ++ { ++ rpmdbFreeIterator_p (mi_debuginfo); ++ count = 0; ++ break; ++ } ++ ++ /* The allocated memory gets utilized below for MISSING_RPM_HASH. */ ++ debuginfo = headerFormat_p (h, ++ "%{name}-%{version}-%{release}.%{arch}", ++ &err); ++ if (!debuginfo) ++ { ++ warning (_("Error querying the rpm file `%s': %s"), filename, ++ err); ++ continue; ++ } ++ ++ /* Base package name for `debuginfo-install'. We do not use the ++ `yum' command directly as the line ++ yum --enablerepo='*debug*' install NAME-debuginfo.ARCH ++ would be more complicated than just: ++ debuginfo-install NAME-VERSION-RELEASE.ARCH ++ Do not supply the rpm base name (derived from .src.rpm name) as ++ debuginfo-install is unable to install the debuginfo package if ++ the base name PKG binary rpm is not installed while for example ++ PKG-libs would be installed (RH Bug 467901). ++ FUTURE: After multiple debuginfo versions simultaneously installed ++ get supported the support for the VERSION-RELEASE tags handling ++ may need an update. */ ++ ++ if (missing_rpm_hash == NULL) ++ { ++ /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE ++ should not deallocate the entries. */ ++ ++ missing_rpm_hash = htab_create_alloc (64, htab_hash_string, ++ (int (*) (const void *, const void *)) streq, ++ NULL, xcalloc, xfree); ++ } ++ slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT); ++ /* XCALLOC never returns NULL. */ ++ gdb_assert (slot != NULL); ++ if (*slot == NULL) ++ { ++ struct missing_rpm *missing_rpm; ++ ++ *slot = debuginfo; ++ ++ missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo)); ++ strcpy (missing_rpm->rpm, debuginfo); ++ missing_rpm->next = missing_rpm_list; ++ missing_rpm_list = missing_rpm; ++ missing_rpm_list_entries++; ++ } ++ else ++ xfree (debuginfo); ++ count++; ++ } ++ ++ rpmdbFreeIterator_p (mi); ++ } ++ ++ rpmtsFree_p (ts); ++ ++ return count; ++} ++ ++static bool ++missing_rpm_list_compar (const char *ap, const char *bp) ++{ ++ return strcoll (ap, bp) < 0; ++} ++ ++/* It returns a NULL-terminated array of strings needing to be FREEd. It may ++ also return only NULL. */ ++ ++static void ++missing_rpm_list_print (void) ++{ ++ struct missing_rpm *list_iter; ++ ++ if (missing_rpm_list_entries == 0) ++ return; ++ ++ std::vector array (missing_rpm_list_entries); ++ size_t idx = 0; ++ ++ for (list_iter = missing_rpm_list; list_iter != NULL; ++ list_iter = list_iter->next) ++ { ++ array[idx++] = list_iter->rpm; ++ } ++ gdb_assert (idx == missing_rpm_list_entries); ++ ++ std::sort (array.begin (), array.end (), missing_rpm_list_compar); ++ ++ /* We zero out the number of missing RPMs here because of a nasty ++ bug (see RHBZ 1801974). ++ ++ When we call 'puts_unfiltered' below, if pagination is on and if ++ the number of missing RPMs is big enough to trigger pagination, ++ we will end up in an infinite recursion. The call chain looks ++ like this: ++ ++ missing_rpm_list_print -> puts_unfiltered -> fputs_maybe_filtered ++ -> prompt_for_continue -> display_gdb_prompt -> ++ debug_flush_missing -> missing_rpm_list_print ... ++ ++ For this reason, we make sure MISSING_RPM_LIST_ENTRIES is zero ++ *before* calling any print function. */ ++ missing_rpm_list_entries = 0; ++ ++ printf_unfiltered (_("Missing separate debuginfos, use: %s"), ++#ifdef DNF_DEBUGINFO_INSTALL ++ "dnf " ++#endif ++ "debuginfo-install"); ++ for (const char *el : array) ++ { ++ puts_unfiltered (" "); ++ puts_unfiltered (el); ++ } ++ puts_unfiltered ("\n"); ++ ++ while (missing_rpm_list != NULL) ++ { ++ list_iter = missing_rpm_list; ++ missing_rpm_list = list_iter->next; ++ xfree (list_iter); ++ } ++} ++ ++static void ++missing_rpm_change (void) ++{ ++ debug_flush_missing (); ++ ++ gdb_assert (missing_rpm_list == NULL); ++ if (missing_rpm_hash != NULL) ++ { ++ htab_delete (missing_rpm_hash); ++ missing_rpm_hash = NULL; ++ } ++} ++ ++enum missing_exec ++ { ++ /* Init state. EXEC_BFD also still could be NULL. */ ++ MISSING_EXEC_NOT_TRIED, ++ /* We saw a non-NULL EXEC_BFD but RPM has no info about it. */ ++ MISSING_EXEC_NOT_FOUND, ++ /* We found EXEC_BFD by RPM and we either have its symbols (either embedded ++ or separate) or the main executable's RPM is now contained in ++ MISSING_RPM_HASH. */ ++ MISSING_EXEC_ENLISTED ++ }; ++static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED; ++ ++#endif /* HAVE_LIBRPM */ ++ ++void ++debug_flush_missing (void) ++{ ++#ifdef HAVE_LIBRPM ++ missing_rpm_list_print (); ++#endif ++} ++ + /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages +- Try to install the hash file ... ++ yum --enablerepo='*debug*' install ... + avoidance. */ + + struct missing_filepair +@@ -752,11 +1119,17 @@ missing_filepair_change (void) + /* All their memory came just from missing_filepair_OBSTACK. */ + missing_filepair_hash = NULL; + } ++#ifdef HAVE_LIBRPM ++ missing_exec = MISSING_EXEC_NOT_TRIED; ++#endif + } + + static void + debug_print_executable_changed (void) + { ++#ifdef HAVE_LIBRPM ++ missing_rpm_change (); ++#endif + missing_filepair_change (); + } + +@@ -823,14 +1196,38 @@ debug_print_missing (const char *binary, + + *slot = missing_filepair; + +- /* We do not collect and flush these messages as each such message +- already requires its own separate lines. */ ++#ifdef HAVE_LIBRPM ++ if (missing_exec == MISSING_EXEC_NOT_TRIED) ++ { ++ const char *execfilename = get_exec_file (0); + +- fprintf_unfiltered (gdb_stdlog, +- _("Missing separate debuginfo for %s\n"), binary); +- if (debug != NULL) +- fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"), +- debug); ++ if (execfilename != NULL) ++ { ++ if (missing_rpm_enlist (execfilename) == 0) ++ missing_exec = MISSING_EXEC_NOT_FOUND; ++ else ++ missing_exec = MISSING_EXEC_ENLISTED; ++ } ++ } ++ if (missing_exec != MISSING_EXEC_ENLISTED) ++ if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0) ++ && (debug == NULL || missing_rpm_enlist (debug) == 0)) ++#endif /* HAVE_LIBRPM */ ++ { ++ /* We do not collect and flush these messages as each such message ++ already requires its own separate lines. */ ++ ++ fprintf_unfiltered (gdb_stdlog, ++ _("Missing separate debuginfo for %s\n"), binary); ++ if (debug != NULL) ++ fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"), ++#ifdef DNF_DEBUGINFO_INSTALL ++ "dnf" ++#else ++ "yum" ++#endif ++ " --enablerepo='*debug*' install", debug); ++ } + } + + /* See build-id.h. */ +diff -Naurp insight-11.0.50.20201205.orig/gdb/config.in insight-11.0.50.20201205.new/gdb/config.in +--- insight-11.0.50.20201205.orig/gdb/config.in 2020-11-20 09:42:30.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/config.in 2020-12-14 17:09:07.892076038 +0100 +@@ -39,6 +39,9 @@ + /* Handle .ctf type-info sections */ + #undef ENABLE_LIBCTF + ++/* librpm version specific library name to dlopen. */ ++#undef DLOPEN_LIBRPM ++ + /* Define to 1 if translation of program messages to the user's native + language is requested. */ + #undef ENABLE_NLS +@@ -247,6 +250,9 @@ + /* Define if you have the mpfr library. */ + #undef HAVE_LIBMPFR + ++/* Define if librpm library is being used. */ ++#undef HAVE_LIBRPM ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_LIBUNWIND_IA64_H + +diff -Naurp insight-11.0.50.20201205.orig/gdb/configure insight-11.0.50.20201205.new/gdb/configure +--- insight-11.0.50.20201205.orig/gdb/configure 2020-12-05 17:05:33.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/configure 2020-12-14 17:09:07.895076067 +0100 +@@ -774,6 +774,11 @@ PKG_CONFIG + HAVE_NATIVE_GCORE_TARGET + TARGET_OBS + subdirs ++RPM_LIBS ++RPM_CFLAGS ++PKG_CONFIG_LIBDIR ++PKG_CONFIG_PATH ++PKG_CONFIG + GDB_DATADIR + DEBUGDIR + MAKEINFO_EXTRA_FLAGS +@@ -878,6 +883,7 @@ with_gdb_datadir + with_relocated_sources + with_auto_load_dir + with_auto_load_safe_path ++with_rpm + enable_targets + enable_64_bit_bfd + enable_gdbmi +@@ -956,6 +962,8 @@ PKG_CONFIG_PATH + PKG_CONFIG_LIBDIR + DEBUGINFOD_CFLAGS + DEBUGINFOD_LIBS ++RPM_CFLAGS ++RPM_LIBS + YACC + YFLAGS + XMKMF' +@@ -1628,6 +1636,8 @@ Optional Packages: + do not restrict auto-loaded files locations + --with-debuginfod Enable debuginfo lookups with debuginfod + (auto/yes/no) ++ --with-rpm query rpm database for missing debuginfos (yes/no, ++ def. auto=librpm.so) + --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets + --with-curses use the curses library instead of the termcap + library +@@ -1712,6 +1722,8 @@ Some influential environment variables: + C compiler flags for DEBUGINFOD, overriding pkg-config + DEBUGINFOD_LIBS + linker flags for DEBUGINFOD, overriding pkg-config ++ RPM_CFLAGS C compiler flags for RPM, overriding pkg-config ++ RPM_LIBS linker flags for RPM, overriding pkg-config + YACC The `Yet Another Compiler Compiler' implementation to use. + Defaults to the first program found out of: `bison -y', `byacc', + `yacc'. +@@ -6604,6 +6616,494 @@ _ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5 + $as_echo "$with_auto_load_safe_path" >&6; } + ++# Integration with rpm library to support missing debuginfo suggestions. ++# --without-rpm: Disable any rpm support. ++# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime. ++# Even with runtime missing `libname.so' GDB will still other run correctly. ++# Missing `libname.so' during ./configure will abort the configuration. ++# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific ++# minor version first such as `librpm-4.6.so' as minor version differences ++# mean API+ABI incompatibility. If the specific match versioned library name ++# could not be found still open dynamically at least `librpm.so'. ++# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try ++# to find librpm for compilation-time linking by pkg-config. GDB binary will ++# be probably linked with the version specific library (as `librpm-4.6.so'). ++# Failure to find librpm by pkg-config will abort the configuration. ++# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config ++# cannot find librpm use to the rpmless compilation (like `--without-rpm'). ++ ++ ++# Check whether --with-rpm was given. ++if test "${with_rpm+set}" = set; then : ++ withval=$with_rpm; ++else ++ with_rpm="auto" ++fi ++ ++ ++ ++ ++if test "x$with_rpm" != "xno"; then ++ if test "x$with_rpm" = "xyes"; then ++ LIBRPM="librpm.so" ++ RPM_REQUIRE=true ++ DLOPEN_REQUIRE=false ++ elif test "x$with_rpm" = "xauto"; then ++ LIBRPM="librpm.so" ++ RPM_REQUIRE=false ++ DLOPEN_REQUIRE=false ++ else ++ LIBRPM="$with_rpm" ++ RPM_REQUIRE=true ++ DLOPEN_REQUIRE=true ++ fi ++ LIBRPM_STRING='"'"$LIBRPM"'"' ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5 ++$as_echo_n "checking specific librpm version... " >&6; } ++ HAVE_DLOPEN_LIBRPM=false ++ save_LIBS="$LIBS" ++ LIBS="$LIBS -ldl" ++ if test "$cross_compiling" = yes; then : ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error "cannot run test program while cross compiling ++See \`config.log' for more details." "$LINENO" 5; } ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++#include ++#include ++#include ++ ++int ++main () ++{ ++ ++ void *h; ++ const char *const *rpmverp; ++ FILE *f; ++ ++ f = fopen ("conftest.out", "w"); ++ if (!f) ++ { ++ fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out", ++ strerror (errno)); ++ return 1; ++ } ++ h = dlopen ($LIBRPM_STRING, RTLD_LAZY); ++ if (!h) ++ { ++ fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ()); ++ return 1; ++ } ++ rpmverp = dlsym (h, "RPMVERSION"); ++ if (!rpmverp) ++ { ++ fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ()); ++ return 1; ++ } ++ fprintf (stderr, "RPMVERSION is: \""); ++ fprintf (stderr, "%s\"\n", *rpmverp); ++ ++ /* Try to find the specific librpm version only for "librpm.so" as we do ++ not know how to assemble the version string otherwise. */ ++ ++ if (strcmp ("librpm.so", $LIBRPM_STRING) != 0) ++ { ++ fprintf (f, "%s\n", $LIBRPM_STRING); ++ return 0; ++ } ++ else ++ { ++ char *h2_name; ++ void *h2; ++ int major, minor; ++ ++ if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2) ++ { ++ fprintf (stderr, "Unable to parse RPMVERSION.\n"); ++ fprintf (f, "%s\n", $LIBRPM_STRING); ++ return 0; ++ } ++ /* Avoid the square brackets by malloc. */ ++ h2_name = malloc (64); ++ sprintf (h2_name, "librpm-%d.%d.so", major, minor); ++ h2 = dlopen (h2_name, RTLD_LAZY); ++ if (!h2) ++ { ++ fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ()); ++ fprintf (f, "%s\n", $LIBRPM_STRING); ++ return 0; ++ } ++ if (h2 != h) ++ { ++ fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n", ++ $LIBRPM_STRING, h2_name); ++ fprintf (f, "%s\n", $LIBRPM_STRING); ++ return 0; ++ } ++ /* Found the valid .so name with a specific version. */ ++ fprintf (f, "%s\n", h2_name); ++ return 0; ++ } ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_run "$LINENO"; then : ++ ++ DLOPEN_LIBRPM="`cat conftest.out`" ++ if test "x$DLOPEN_LIBRPM" != "x"; then ++ HAVE_DLOPEN_LIBRPM=true ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5 ++$as_echo "$DLOPEN_LIBRPM" >&6; } ++ fi ++ ++fi ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ ++ conftest.$ac_objext conftest.beam conftest.$ac_ext ++fi ++ ++ rm -f conftest.out ++ ++ ++ ++ if $HAVE_DLOPEN_LIBRPM; then ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5 ++$as_echo_n "checking rpm library API compatibility... " >&6; } ++ # The compilation requires -Werror to verify anything. ++ save_CFLAGS="$CFLAGS" ++ CFLAGS="$CFLAGS -Werror" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Duplicate here the declarations to verify they match "elfread.c". */ ++#include ++#include ++#include ++#include ++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); ++extern int rpmReadConfigFiles(const char * file, const char * target); ++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); ++extern Header rpmdbNextIterator(rpmdbMatchIterator mi); ++extern rpmts rpmtsCreate(void); ++extern rpmts rpmtsFree(rpmts ts); ++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, ++ const void * keyp, size_t keylen); ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ++ LIBRPM_COMPAT=true ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++else ++ ++ LIBRPM_COMPAT=false ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ CFLAGS="$save_CFLAGS" ++ ++ if ! $LIBRPM_COMPAT; then ++ HAVE_DLOPEN_LIBRPM=false ++ fi ++ fi ++ ++ if $HAVE_DLOPEN_LIBRPM; then ++ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"' ++ ++cat >>confdefs.h <<_ACEOF ++#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING ++_ACEOF ++ ++ ++$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h ++ ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ LIBS="$save_LIBS" ++ if $DLOPEN_REQUIRE; then ++ as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5 ++ fi ++ ++ ++ ++ ++ ++ ++ ++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. ++set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ case $PKG_CONFIG in ++ [\\/]* | ?:[\\/]*) ++ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ++ ;; ++ *) ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++ ;; ++esac ++fi ++PKG_CONFIG=$ac_cv_path_PKG_CONFIG ++if test -n "$PKG_CONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 ++$as_echo "$PKG_CONFIG" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_path_PKG_CONFIG"; then ++ ac_pt_PKG_CONFIG=$PKG_CONFIG ++ # Extract the first word of "pkg-config", so it can be a program name with args. ++set dummy pkg-config; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ case $ac_pt_PKG_CONFIG in ++ [\\/]* | ?:[\\/]*) ++ ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ++ ;; ++ *) ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++ ;; ++esac ++fi ++ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG ++if test -n "$ac_pt_PKG_CONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 ++$as_echo "$ac_pt_PKG_CONFIG" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_pt_PKG_CONFIG" = x; then ++ PKG_CONFIG="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ PKG_CONFIG=$ac_pt_PKG_CONFIG ++ fi ++else ++ PKG_CONFIG="$ac_cv_path_PKG_CONFIG" ++fi ++ ++fi ++if test -n "$PKG_CONFIG"; then ++ _pkg_min_version=0.9.0 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 ++$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } ++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ PKG_CONFIG="" ++ fi ++fi ++ ++pkg_failed=no ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5 ++$as_echo_n "checking for RPM... " >&6; } ++ ++if test -n "$RPM_CFLAGS"; then ++ pkg_cv_RPM_CFLAGS="$RPM_CFLAGS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++if test -n "$RPM_LIBS"; then ++ pkg_cv_RPM_LIBS="$RPM_LIBS" ++ elif test -n "$PKG_CONFIG"; then ++ if test -n "$PKG_CONFIG" && \ ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null` ++ test "x$?" != "x0" && pkg_failed=yes ++else ++ pkg_failed=yes ++fi ++ else ++ pkg_failed=untried ++fi ++ ++ ++ ++if test $pkg_failed = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then ++ _pkg_short_errors_supported=yes ++else ++ _pkg_short_errors_supported=no ++fi ++ if test $_pkg_short_errors_supported = yes; then ++ RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1` ++ else ++ RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1` ++ fi ++ # Put the nasty error message in config.log where it belongs ++ echo "$RPM_PKG_ERRORS" >&5 ++ ++ HAVE_LIBRPM=false ++elif test $pkg_failed = untried; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ HAVE_LIBRPM=false ++else ++ RPM_CFLAGS=$pkg_cv_RPM_CFLAGS ++ RPM_LIBS=$pkg_cv_RPM_LIBS ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ HAVE_LIBRPM=true ++fi ++ ++ if $HAVE_LIBRPM; then ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5 ++$as_echo_n "checking rpm library API compatibility... " >&6; } ++ # The compilation requires -Werror to verify anything. ++ save_CFLAGS="$CFLAGS" ++ CFLAGS="$CFLAGS -Werror" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Duplicate here the declarations to verify they match "elfread.c". */ ++#include ++#include ++#include ++#include ++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); ++extern int rpmReadConfigFiles(const char * file, const char * target); ++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); ++extern Header rpmdbNextIterator(rpmdbMatchIterator mi); ++extern rpmts rpmtsCreate(void); ++extern rpmts rpmtsFree(rpmts ts); ++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, ++ const void * keyp, size_t keylen); ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ++ LIBRPM_COMPAT=true ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++else ++ ++ LIBRPM_COMPAT=false ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ CFLAGS="$save_CFLAGS" ++ ++ if ! $LIBRPM_COMPAT; then ++ HAVE_LIBRPM=false ++ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB" ++ fi ++ fi ++ ++ if $HAVE_LIBRPM; then ++ ++$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h ++ ++ CFLAGS="$CFLAGS $RPM_CFLAGS" ++ LIBS="$LIBS $RPM_LIBS" ++ else ++ if $RPM_REQUIRE; then ++ as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5 ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5 ++$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;} ++ fi ++ fi ++ fi ++fi ++ + + + subdirs="$subdirs testsuite" +diff -Naurp insight-11.0.50.20201205.orig/gdb/configure.ac insight-11.0.50.20201205.new/gdb/configure.ac +--- insight-11.0.50.20201205.orig/gdb/configure.ac 2020-12-05 17:05:29.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/configure.ac 2020-12-14 17:09:07.895076067 +0100 +@@ -152,6 +152,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escap + [Directories safe to hold auto-loaded files.]) + AC_MSG_RESULT([$with_auto_load_safe_path]) + ++# Integration with rpm library to support missing debuginfo suggestions. ++# --without-rpm: Disable any rpm support. ++# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime. ++# Even with runtime missing `libname.so' GDB will still other run correctly. ++# Missing `libname.so' during ./configure will abort the configuration. ++# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific ++# minor version first such as `librpm-4.6.so' as minor version differences ++# mean API+ABI incompatibility. If the specific match versioned library name ++# could not be found still open dynamically at least `librpm.so'. ++# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try ++# to find librpm for compilation-time linking by pkg-config. GDB binary will ++# be probably linked with the version specific library (as `librpm-4.6.so'). ++# Failure to find librpm by pkg-config will abort the configuration. ++# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config ++# cannot find librpm use to the rpmless compilation (like `--without-rpm'). ++ ++AC_ARG_WITH([rpm], ++ [AS_HELP_STRING([--with-rpm], ++ [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"]) ++ ++m4_pattern_allow([^AC_MSG_ERROR$]) ++m4_pattern_allow([^AC_MSG_WARN$]) ++if test "x$with_rpm" != "xno"; then ++ if test "x$with_rpm" = "xyes"; then ++ LIBRPM="librpm.so" ++ RPM_REQUIRE=true ++ DLOPEN_REQUIRE=false ++ elif test "x$with_rpm" = "xauto"; then ++ LIBRPM="librpm.so" ++ RPM_REQUIRE=false ++ DLOPEN_REQUIRE=false ++ else ++ LIBRPM="$with_rpm" ++ RPM_REQUIRE=true ++ DLOPEN_REQUIRE=true ++ fi ++ LIBRPM_STRING='"'"$LIBRPM"'"' ++ ++ AC_MSG_CHECKING([specific librpm version]) ++ HAVE_DLOPEN_LIBRPM=false ++ save_LIBS="$LIBS" ++ LIBS="$LIBS -ldl" ++ AC_RUN_IFELSE(AC_LANG_PROGRAM([[ ++#include ++#include ++#include ++ ]], [[ ++ void *h; ++ const char *const *rpmverp; ++ FILE *f; ++ ++ f = fopen ("conftest.out", "w"); ++ if (!f) ++ { ++ fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out", ++ strerror (errno)); ++ return 1; ++ } ++ h = dlopen ($LIBRPM_STRING, RTLD_LAZY); ++ if (!h) ++ { ++ fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ()); ++ return 1; ++ } ++ rpmverp = dlsym (h, "RPMVERSION"); ++ if (!rpmverp) ++ { ++ fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ()); ++ return 1; ++ } ++ fprintf (stderr, "RPMVERSION is: \""); ++ fprintf (stderr, "%s\"\n", *rpmverp); ++ ++ /* Try to find the specific librpm version only for "librpm.so" as we do ++ not know how to assemble the version string otherwise. */ ++ ++ if (strcmp ("librpm.so", $LIBRPM_STRING) != 0) ++ { ++ fprintf (f, "%s\n", $LIBRPM_STRING); ++ return 0; ++ } ++ else ++ { ++ char *h2_name; ++ void *h2; ++ int major, minor; ++ ++ if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2) ++ { ++ fprintf (stderr, "Unable to parse RPMVERSION.\n"); ++ fprintf (f, "%s\n", $LIBRPM_STRING); ++ return 0; ++ } ++ /* Avoid the square brackets by malloc. */ ++ h2_name = malloc (64); ++ sprintf (h2_name, "librpm-%d.%d.so", major, minor); ++ h2 = dlopen (h2_name, RTLD_LAZY); ++ if (!h2) ++ { ++ fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ()); ++ fprintf (f, "%s\n", $LIBRPM_STRING); ++ return 0; ++ } ++ if (h2 != h) ++ { ++ fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n", ++ $LIBRPM_STRING, h2_name); ++ fprintf (f, "%s\n", $LIBRPM_STRING); ++ return 0; ++ } ++ /* Found the valid .so name with a specific version. */ ++ fprintf (f, "%s\n", h2_name); ++ return 0; ++ } ++ ]]), [ ++ DLOPEN_LIBRPM="`cat conftest.out`" ++ if test "x$DLOPEN_LIBRPM" != "x"; then ++ HAVE_DLOPEN_LIBRPM=true ++ AC_MSG_RESULT($DLOPEN_LIBRPM) ++ fi ++ ]) ++ rm -f conftest.out ++ ++ m4_define([CHECK_LIBRPM_COMPAT], [ ++ AC_MSG_CHECKING([rpm library API compatibility]) ++ # The compilation requires -Werror to verify anything. ++ save_CFLAGS="$CFLAGS" ++ CFLAGS="$CFLAGS -Werror" ++ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ ++/* Duplicate here the declarations to verify they match "elfread.c". */ ++#include ++#include ++#include ++#include ++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); ++extern int rpmReadConfigFiles(const char * file, const char * target); ++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); ++extern Header rpmdbNextIterator(rpmdbMatchIterator mi); ++extern rpmts rpmtsCreate(void); ++extern rpmts rpmtsFree(rpmts ts); ++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, ++ const void * keyp, size_t keylen); ++ ]]), [ ++ LIBRPM_COMPAT=true ++ AC_MSG_RESULT(yes) ++ ], [ ++ LIBRPM_COMPAT=false ++ AC_MSG_RESULT(no) ++ ]) ++ CFLAGS="$save_CFLAGS" ++ ]) ++ ++ if $HAVE_DLOPEN_LIBRPM; then ++ CHECK_LIBRPM_COMPAT ++ if ! $LIBRPM_COMPAT; then ++ HAVE_DLOPEN_LIBRPM=false ++ fi ++ fi ++ ++ if $HAVE_DLOPEN_LIBRPM; then ++ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"' ++ AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.]) ++ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.]) ++ else ++ AC_MSG_RESULT(no) ++ LIBS="$save_LIBS" ++ if $DLOPEN_REQUIRE; then ++ AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.]) ++ fi ++ PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false]) ++ ++ if $HAVE_LIBRPM; then ++ CHECK_LIBRPM_COMPAT ++ if ! $LIBRPM_COMPAT; then ++ HAVE_LIBRPM=false ++ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB" ++ fi ++ fi ++ ++ if $HAVE_LIBRPM; then ++ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.]) ++ CFLAGS="$CFLAGS $RPM_CFLAGS" ++ LIBS="$LIBS $RPM_LIBS" ++ else ++ if $RPM_REQUIRE; then ++ AC_MSG_ERROR($RPM_PKG_ERRORS) ++ else ++ AC_MSG_WARN($RPM_PKG_ERRORS) ++ fi ++ fi ++ fi ++fi ++ + AC_CONFIG_SUBDIRS(testsuite) + + # Check whether to support alternative target configurations +diff -Naurp insight-11.0.50.20201205.orig/gdb/event-top.c insight-11.0.50.20201205.new/gdb/event-top.c +--- insight-11.0.50.20201205.orig/gdb/event-top.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/event-top.c 2020-12-14 17:09:07.896076076 +0100 +@@ -42,6 +42,7 @@ + #include "gdbsupport/gdb_select.h" + #include "gdbsupport/gdb-sigmask.h" + #include "async-event.h" ++#include "symfile.h" + + /* readline include files. */ + #include "readline/readline.h" +@@ -364,6 +365,8 @@ display_gdb_prompt (const char *new_prom + /* Reset the nesting depth used when trace-commands is set. */ + reset_command_nest_depth (); + ++ debug_flush_missing (); ++ + /* Do not call the python hook on an explicit prompt change as + passed to this function, as this forms a secondary/local prompt, + IE, displayed but not set. */ +@@ -774,7 +777,10 @@ command_line_handler (gdb::unique_xmallo + command_handler (cmd); + + if (ui->prompt_state != PROMPTED) +- display_gdb_prompt (0); ++ { ++ debug_flush_missing (); ++ display_gdb_prompt (0); ++ } + } + } + +diff -Naurp insight-11.0.50.20201205.orig/gdb/symfile.h insight-11.0.50.20201205.new/gdb/symfile.h +--- insight-11.0.50.20201205.orig/gdb/symfile.h 2020-12-14 17:08:00.345429069 +0100 ++++ insight-11.0.50.20201205.new/gdb/symfile.h 2020-12-14 17:09:07.896076076 +0100 +@@ -556,6 +556,7 @@ extern void generic_load (const char *ar + /* build-id support. */ + extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); + extern void debug_print_missing (const char *binary, const char *debug); ++extern void debug_flush_missing (void); + #define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") + + /* From dwarf2read.c */ diff --git a/insight-11.0-gdb-6.6-buildid-locate-solib-missing-ids.patch b/insight-11.0-gdb-6.6-buildid-locate-solib-missing-ids.patch new file mode 100644 index 0000000..31a1624 --- /dev/null +++ b/insight-11.0-gdb-6.6-buildid-locate-solib-missing-ids.patch @@ -0,0 +1,221 @@ +diff -Naurp insight-11.0.50.20201205.orig/gdb/solib-svr4.c insight-11.0.50.20201205.new/gdb/solib-svr4.c +--- insight-11.0.50.20201205.orig/gdb/solib-svr4.c 2020-12-14 16:45:41.961609916 +0100 ++++ insight-11.0.50.20201205.new/gdb/solib-svr4.c 2020-12-14 17:06:24.225508428 +0100 +@@ -1345,14 +1345,27 @@ svr4_read_so_list (svr4_info *info, CORE + } + + { +- struct bfd_build_id *build_id; ++ struct bfd_build_id *build_id = NULL; + + strncpy (newobj->so_original_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1); + newobj->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; + /* May get overwritten below. */ + strcpy (newobj->so_name, newobj->so_original_name); + +- build_id = build_id_addr_get (((lm_info_svr4 *) newobj->lm_info)->l_ld); ++ /* In the case the main executable was found according to its build-id ++ (from a core file) prevent loading a different build of a library ++ with accidentally the same SO_NAME. ++ ++ It suppresses bogus backtraces (and prints "??" there instead) if ++ the on-disk files no longer match the running program version. ++ ++ If the main executable was not loaded according to its build-id do ++ not do any build-id checking of the libraries. There may be missing ++ build-ids dumped in the core file and we would map all the libraries ++ to the only existing file loaded that time - the executable. */ ++ if (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; +@@ -1367,23 +1380,7 @@ svr4_read_so_list (svr4_info *info, CORE + xfree (name); + } + else +- { +- debug_print_missing (newobj->so_name, build_id_filename); +- +- /* In the case the main executable was found according to +- its build-id (from a core file) prevent loading +- a different build of a library with accidentally the +- same SO_NAME. +- +- It suppresses bogus backtraces (and prints "??" there +- instead) if the on-disk files no longer match the +- running program version. */ +- +- if (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; +- } ++ debug_print_missing (newobj->so_name, build_id_filename); + + xfree (build_id_filename); + xfree (build_id); +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp 1970-01-01 01:00:00.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib.exp 2020-12-14 16:46:42.303187870 +0100 +@@ -0,0 +1,105 @@ ++# Copyright 2016 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++if {[skip_shlib_tests]} { ++ return 0 ++} ++ ++set testfile "gcore-buildid-exec-but-not-solib" ++set srcmainfile ${testfile}-main.c ++set srclibfile ${testfile}-lib.c ++set libfile [standard_output_file ${testfile}-lib.so] ++set objfile [standard_output_file ${testfile}-main.o] ++set executable ${testfile}-main ++set binfile [standard_output_file ${executable}] ++set gcorefile [standard_output_file ${executable}.gcore] ++set outdir [file dirname $binfile] ++ ++if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} "debug additional_flags=-Wl,--build-id"] != "" ++ || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } { ++ unsupported "-Wl,--build-id compilation failed" ++ return -1 ++} ++set opts [list debug shlib=${libfile} "additional_flags=-Wl,--build-id"] ++if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } { ++ unsupported "-Wl,--build-id compilation failed" ++ return -1 ++} ++ ++clean_restart $executable ++gdb_load_shlib $libfile ++ ++# Does this gdb support gcore? ++set test "help gcore" ++gdb_test_multiple $test $test { ++ -re "Undefined command: .gcore.*\r\n$gdb_prompt $" { ++ # gcore command not supported -- nothing to test here. ++ unsupported "gdb does not support gcore on this target" ++ return -1; ++ } ++ -re "Save a core file .*\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++if { ![runto lib] } then { ++ return -1 ++} ++ ++set escapedfilename [string_to_regexp ${gcorefile}] ++ ++set test "save a corefile" ++gdb_test_multiple "gcore ${gcorefile}" $test { ++ -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "Can't create a corefile\r\n$gdb_prompt $" { ++ unsupported $test ++ return -1 ++ } ++} ++ ++# Now restart gdb and load the corefile. ++ ++clean_restart $executable ++gdb_load_shlib $libfile ++ ++set buildid [build_id_debug_filename_get $libfile] ++ ++regsub {\.debug$} $buildid {} buildid ++ ++set debugdir [standard_output_file ${testfile}-debugdir] ++file delete -force -- $debugdir ++ ++file mkdir $debugdir/[file dirname $libfile] ++file copy $libfile $debugdir/${libfile} ++ ++file mkdir $debugdir/[file dirname $buildid] ++file copy $libfile $debugdir/${buildid} ++ ++remote_exec build "ln -s /lib ${debugdir}/" ++remote_exec build "ln -s /lib64 ${debugdir}/" ++# /usr is not needed, all the libs are in /lib64: libm.so.6 libc.so.6 ld-linux-x86-64.so.2 ++ ++gdb_test "set solib-absolute-prefix $debugdir" ++ ++gdb_test_no_output "set debug-file-directory $debugdir" "set debug-file-directory" ++ ++gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile" ++ ++gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded" ++ ++gdb_test "bt" ++gdb_test "info shared" +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c 1970-01-01 01:00:00.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-lib.c 2020-12-14 16:46:42.302187861 +0100 +@@ -0,0 +1,21 @@ ++/* Copyright 2010 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++void ++lib (void) ++{ ++} +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c 1970-01-01 01:00:00.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/gcore-buildid-exec-but-not-solib-main.c 2020-12-14 16:46:42.302187861 +0100 +@@ -0,0 +1,25 @@ ++/* Copyright 2010 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++extern void lib (void); ++ ++int ++main (void) ++{ ++ lib (); ++ return 0; ++} diff --git a/insight-11.0-gdb-6.6-buildid-locate.patch b/insight-11.0-gdb-6.6-buildid-locate.patch new file mode 100644 index 0000000..0c649a4 --- /dev/null +++ b/insight-11.0-gdb-6.6-buildid-locate.patch @@ -0,0 +1,1407 @@ +diff -Naurp insight-11.0.50.20201205.orig/bfd/libbfd.h insight-11.0.50.20201205.new/bfd/libbfd.h +--- insight-11.0.50.20201205.orig/bfd/libbfd.h 2020-09-16 18:57:42.000000000 +0200 ++++ insight-11.0.50.20201205.new/bfd/libbfd.h 2020-12-13 19:21:45.203850603 +0100 +@@ -126,7 +126,7 @@ static inline char * + bfd_strdup (const char *str) + { + size_t len = strlen (str) + 1; +- char *buf = bfd_malloc (len); ++ char *buf = (char *) bfd_malloc (len); + if (buf != NULL) + memcpy (buf, str, len); + return buf; +diff -Naurp insight-11.0.50.20201205.orig/bfd/libbfd-in.h insight-11.0.50.20201205.new/bfd/libbfd-in.h +--- insight-11.0.50.20201205.orig/bfd/libbfd-in.h 2020-09-16 18:57:42.000000000 +0200 ++++ insight-11.0.50.20201205.new/bfd/libbfd-in.h 2020-12-13 19:21:45.203850603 +0100 +@@ -121,7 +121,7 @@ static inline char * + bfd_strdup (const char *str) + { + size_t len = strlen (str) + 1; +- char *buf = bfd_malloc (len); ++ char *buf = (char *) bfd_malloc (len); + if (buf != NULL) + memcpy (buf, str, len); + return buf; +diff -Naurp insight-11.0.50.20201205.orig/gdb/build-id.c insight-11.0.50.20201205.new/gdb/build-id.c +--- insight-11.0.50.20201205.orig/gdb/build-id.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/build-id.c 2020-12-13 19:21:45.204850613 +0100 +@@ -24,13 +24,70 @@ + #include "gdbsupport/gdb_vecs.h" + #include "symfile.h" + #include "objfiles.h" ++#include ++#include "elf-bfd.h" ++#include "elf/common.h" ++#include "elf/external.h" ++#include "elf/internal.h" + #include "filenames.h" ++#include "gdb_bfd.h" ++#include "gdbcmd.h" + #include "gdbcore.h" ++#include "objfiles.h" ++#include "observable.h" ++#include "symfile.h" ++ ++#define BUILD_ID_VERBOSE_NONE 0 ++#define BUILD_ID_VERBOSE_FILENAMES 1 ++#define BUILD_ID_VERBOSE_BINARY_PARSE 2 ++static int build_id_verbose = BUILD_ID_VERBOSE_FILENAMES; ++static void ++show_build_id_verbose (struct ui_file *file, int from_tty, ++ struct cmd_list_element *c, const char *value) ++{ ++ fprintf_filtered (file, _("Verbosity level of the build-id locator is %s.\n"), ++ value); ++} ++/* Locate NT_GNU_BUILD_ID and return its matching debug filename. ++ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */ ++ ++static struct bfd_build_id * ++build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size) ++{ ++ bfd_byte *p; ++ ++ p = buf; ++ while (p < buf + size) ++ { ++ /* FIXME: bad alignment assumption. */ ++ Elf_External_Note *xnp = (Elf_External_Note *) p; ++ size_t namesz = H_GET_32 (templ, xnp->namesz); ++ size_t descsz = H_GET_32 (templ, xnp->descsz); ++ bfd_byte *descdata = (gdb_byte *) xnp->name + BFD_ALIGN (namesz, 4); ++ ++ if (H_GET_32 (templ, xnp->type) == NT_GNU_BUILD_ID ++ && namesz == sizeof "GNU" ++ && memcmp (xnp->name, "GNU", sizeof "GNU") == 0) ++ { ++ size_t sz = descsz; ++ gdb_byte *data = (gdb_byte *) descdata; ++ struct bfd_build_id *retval; ++ ++ retval = (struct bfd_build_id *) xmalloc (sizeof *retval - 1 + sz); ++ retval->size = sz; ++ memcpy (retval->data, data, sz); ++ ++ return retval; ++ } ++ p = descdata + BFD_ALIGN (descsz, 4); ++ } ++ return NULL; ++} + + /* See build-id.h. */ + + const struct bfd_build_id * +-build_id_bfd_get (bfd *abfd) ++build_id_bfd_shdr_get (bfd *abfd) + { + if (!bfd_check_format (abfd, bfd_object) + && !bfd_check_format (abfd, bfd_core)) +@@ -43,6 +100,348 @@ build_id_bfd_get (bfd *abfd) + return NULL; + } + ++/* Core files may have missing (corrupt) SHDR but PDHR is correct there. ++ bfd_elf_bfd_from_remote_memory () has too much overhead by ++ allocating/reading all the available ELF PT_LOADs. */ ++ ++static struct bfd_build_id * ++build_id_phdr_get (bfd *templ, bfd_vma loadbase, unsigned e_phnum, ++ Elf_Internal_Phdr *i_phdr) ++{ ++ int i; ++ struct bfd_build_id *retval = NULL; ++ ++ for (i = 0; i < e_phnum; i++) ++ if (i_phdr[i].p_type == PT_NOTE && i_phdr[i].p_filesz > 0) ++ { ++ Elf_Internal_Phdr *hdr = &i_phdr[i]; ++ gdb_byte *buf; ++ int err; ++ ++ buf = (gdb_byte *) xmalloc (hdr->p_filesz); ++ err = target_read_memory (loadbase + i_phdr[i].p_vaddr, buf, ++ hdr->p_filesz); ++ if (err == 0) ++ retval = build_id_buf_get (templ, buf, hdr->p_filesz); ++ else ++ retval = NULL; ++ xfree (buf); ++ if (retval != NULL) ++ break; ++ } ++ return retval; ++} ++ ++/* First we validate the file by reading in the ELF header and checking ++ the magic number. */ ++ ++static inline bfd_boolean ++elf_file_p (Elf64_External_Ehdr *x_ehdrp64) ++{ ++ gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr)); ++ gdb_assert (offsetof (Elf64_External_Ehdr, e_ident) ++ == offsetof (Elf32_External_Ehdr, e_ident)); ++ gdb_assert (sizeof (((Elf64_External_Ehdr *) 0)->e_ident) ++ == sizeof (((Elf32_External_Ehdr *) 0)->e_ident)); ++ ++ return ((x_ehdrp64->e_ident[EI_MAG0] == ELFMAG0) ++ && (x_ehdrp64->e_ident[EI_MAG1] == ELFMAG1) ++ && (x_ehdrp64->e_ident[EI_MAG2] == ELFMAG2) ++ && (x_ehdrp64->e_ident[EI_MAG3] == ELFMAG3)); ++} ++ ++/* Translate an ELF file header in external format into an ELF file header in ++ internal format. */ ++ ++#define H_GET_WORD(bfd, ptr) (is64 ? H_GET_64 (bfd, (ptr)) \ ++ : H_GET_32 (bfd, (ptr))) ++#define H_GET_SIGNED_WORD(bfd, ptr) (is64 ? H_GET_S64 (bfd, (ptr)) \ ++ : H_GET_S32 (bfd, (ptr))) ++ ++static void ++elf_swap_ehdr_in (bfd *abfd, ++ const Elf64_External_Ehdr *src64, ++ Elf_Internal_Ehdr *dst) ++{ ++ int is64 = bfd_get_arch_size (abfd) == 64; ++#define SRC(field) (is64 ? src64->field \ ++ : ((const Elf32_External_Ehdr *) src64)->field) ++ ++ int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; ++ memcpy (dst->e_ident, SRC (e_ident), EI_NIDENT); ++ dst->e_type = H_GET_16 (abfd, SRC (e_type)); ++ dst->e_machine = H_GET_16 (abfd, SRC (e_machine)); ++ dst->e_version = H_GET_32 (abfd, SRC (e_version)); ++ if (signed_vma) ++ dst->e_entry = H_GET_SIGNED_WORD (abfd, SRC (e_entry)); ++ else ++ dst->e_entry = H_GET_WORD (abfd, SRC (e_entry)); ++ dst->e_phoff = H_GET_WORD (abfd, SRC (e_phoff)); ++ dst->e_shoff = H_GET_WORD (abfd, SRC (e_shoff)); ++ dst->e_flags = H_GET_32 (abfd, SRC (e_flags)); ++ dst->e_ehsize = H_GET_16 (abfd, SRC (e_ehsize)); ++ dst->e_phentsize = H_GET_16 (abfd, SRC (e_phentsize)); ++ dst->e_phnum = H_GET_16 (abfd, SRC (e_phnum)); ++ dst->e_shentsize = H_GET_16 (abfd, SRC (e_shentsize)); ++ dst->e_shnum = H_GET_16 (abfd, SRC (e_shnum)); ++ dst->e_shstrndx = H_GET_16 (abfd, SRC (e_shstrndx)); ++ ++#undef SRC ++} ++ ++/* Translate an ELF program header table entry in external format into an ++ ELF program header table entry in internal format. */ ++ ++static void ++elf_swap_phdr_in (bfd *abfd, ++ const Elf64_External_Phdr *src64, ++ Elf_Internal_Phdr *dst) ++{ ++ int is64 = bfd_get_arch_size (abfd) == 64; ++#define SRC(field) (is64 ? src64->field \ ++ : ((const Elf32_External_Phdr *) src64)->field) ++ ++ int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; ++ ++ dst->p_type = H_GET_32 (abfd, SRC (p_type)); ++ dst->p_flags = H_GET_32 (abfd, SRC (p_flags)); ++ dst->p_offset = H_GET_WORD (abfd, SRC (p_offset)); ++ if (signed_vma) ++ { ++ dst->p_vaddr = H_GET_SIGNED_WORD (abfd, SRC (p_vaddr)); ++ dst->p_paddr = H_GET_SIGNED_WORD (abfd, SRC (p_paddr)); ++ } ++ else ++ { ++ dst->p_vaddr = H_GET_WORD (abfd, SRC (p_vaddr)); ++ dst->p_paddr = H_GET_WORD (abfd, SRC (p_paddr)); ++ } ++ dst->p_filesz = H_GET_WORD (abfd, SRC (p_filesz)); ++ dst->p_memsz = H_GET_WORD (abfd, SRC (p_memsz)); ++ dst->p_align = H_GET_WORD (abfd, SRC (p_align)); ++ ++#undef SRC ++} ++ ++#undef H_GET_SIGNED_WORD ++#undef H_GET_WORD ++ ++static Elf_Internal_Phdr * ++elf_get_phdr (bfd *templ, bfd_vma ehdr_vma, unsigned *e_phnum_pointer, ++ bfd_vma *loadbase_pointer) ++{ ++ /* sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr) */ ++ Elf64_External_Ehdr x_ehdr64; /* Elf file header, external form */ ++ Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */ ++ bfd_size_type x_phdrs_size; ++ gdb_byte *x_phdrs_ptr; ++ Elf_Internal_Phdr *i_phdrs; ++ int err; ++ unsigned int i; ++ bfd_vma loadbase; ++ int loadbase_set; ++ ++ gdb_assert (templ != NULL); ++ gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr)); ++ ++ /* Read in the ELF header in external format. */ ++ err = target_read_memory (ehdr_vma, (bfd_byte *) &x_ehdr64, sizeof x_ehdr64); ++ if (err) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Error reading ELF header at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ ++ /* Now check to see if we have a valid ELF file, and one that BFD can ++ make use of. The magic number must match, the address size ('class') ++ and byte-swapping must match our XVEC entry. */ ++ ++ if (! elf_file_p (&x_ehdr64) ++ || x_ehdr64.e_ident[EI_VERSION] != EV_CURRENT ++ || !((bfd_get_arch_size (templ) == 64 ++ && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS64) ++ || (bfd_get_arch_size (templ) == 32 ++ && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS32))) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Unrecognized ELF header at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ ++ /* Check that file's byte order matches xvec's */ ++ switch (x_ehdr64.e_ident[EI_DATA]) ++ { ++ case ELFDATA2MSB: /* Big-endian */ ++ if (! bfd_header_big_endian (templ)) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Unrecognized " ++ "big-endian ELF header at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ break; ++ case ELFDATA2LSB: /* Little-endian */ ++ if (! bfd_header_little_endian (templ)) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Unrecognized " ++ "little-endian ELF header at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ break; ++ case ELFDATANONE: /* No data encoding specified */ ++ default: /* Unknown data encoding specified */ ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Unrecognized " ++ "ELF header endianity at address 0x%lx"), ++ (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ ++ elf_swap_ehdr_in (templ, &x_ehdr64, &i_ehdr); ++ ++ /* The file header tells where to find the program headers. ++ These are what we use to actually choose what to read. */ ++ ++ if (i_ehdr.e_phentsize != (bfd_get_arch_size (templ) == 64 ++ ? sizeof (Elf64_External_Phdr) ++ : sizeof (Elf32_External_Phdr)) ++ || i_ehdr.e_phnum == 0) ++ { ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Invalid ELF program headers from the ELF header " ++ "at address 0x%lx"), (unsigned long) ehdr_vma); ++ return NULL; ++ } ++ ++ x_phdrs_size = (bfd_get_arch_size (templ) == 64 ? sizeof (Elf64_External_Phdr) ++ : sizeof (Elf32_External_Phdr)); ++ ++ i_phdrs = (Elf_Internal_Phdr *) xmalloc (i_ehdr.e_phnum * (sizeof *i_phdrs + x_phdrs_size)); ++ x_phdrs_ptr = (gdb_byte *) &i_phdrs[i_ehdr.e_phnum]; ++ err = target_read_memory (ehdr_vma + i_ehdr.e_phoff, (bfd_byte *) x_phdrs_ptr, ++ i_ehdr.e_phnum * x_phdrs_size); ++ if (err) ++ { ++ free (i_phdrs); ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Error reading " ++ "ELF program headers at address 0x%lx"), ++ (unsigned long) (ehdr_vma + i_ehdr.e_phoff)); ++ return NULL; ++ } ++ ++ loadbase = ehdr_vma; ++ loadbase_set = 0; ++ for (i = 0; i < i_ehdr.e_phnum; ++i) ++ { ++ elf_swap_phdr_in (templ, (Elf64_External_Phdr *) ++ (x_phdrs_ptr + i * x_phdrs_size), &i_phdrs[i]); ++ /* IA-64 vDSO may have two mappings for one segment, where one mapping ++ is executable only, and one is read only. We must not use the ++ executable one (PF_R is the first one, PF_X the second one). */ ++ if (i_phdrs[i].p_type == PT_LOAD && (i_phdrs[i].p_flags & PF_R)) ++ { ++ /* Only the first PT_LOAD segment indicates the file bias. ++ Next segments may have P_VADDR arbitrarily higher. ++ If the first segment has P_VADDR zero any next segment must not ++ confuse us, the first one sets LOADBASE certainly enough. */ ++ if (!loadbase_set && i_phdrs[i].p_offset == 0) ++ { ++ loadbase = ehdr_vma - i_phdrs[i].p_vaddr; ++ loadbase_set = 1; ++ } ++ } ++ } ++ ++ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) ++ warning (_("build-id: Found ELF header at address 0x%lx, loadbase 0x%lx"), ++ (unsigned long) ehdr_vma, (unsigned long) loadbase); ++ ++ *e_phnum_pointer = i_ehdr.e_phnum; ++ *loadbase_pointer = loadbase; ++ return i_phdrs; ++} ++ ++/* BUILD_ID_ADDR_GET gets ADDR located somewhere in the object. ++ Find the first section before ADDR containing an ELF header. ++ We rely on the fact the sections from multiple files do not mix. ++ FIXME: We should check ADDR is contained _inside_ the section with possibly ++ missing content (P_FILESZ < P_MEMSZ). These omitted sections are currently ++ hidden by _BFD_ELF_MAKE_SECTION_FROM_PHDR. */ ++ ++static CORE_ADDR build_id_addr; ++struct build_id_addr_sect ++ { ++ struct build_id_addr_sect *next; ++ asection *sect; ++ }; ++static struct build_id_addr_sect *build_id_addr_sect; ++ ++static void build_id_addr_candidate (bfd *abfd, asection *sect, void *obj) ++{ ++ if (build_id_addr >= bfd_section_vma (sect)) ++ { ++ struct build_id_addr_sect *candidate; ++ ++ candidate = (struct build_id_addr_sect *) xmalloc (sizeof *candidate); ++ candidate->next = build_id_addr_sect; ++ build_id_addr_sect = candidate; ++ candidate->sect = sect; ++ } ++} ++ ++struct bfd_build_id * ++build_id_addr_get (CORE_ADDR addr) ++{ ++ struct build_id_addr_sect *candidate; ++ struct bfd_build_id *retval = NULL; ++ Elf_Internal_Phdr *i_phdr = NULL; ++ bfd_vma loadbase = 0; ++ unsigned e_phnum = 0; ++ ++ if (core_bfd == NULL) ++ return NULL; ++ ++ build_id_addr = addr; ++ gdb_assert (build_id_addr_sect == NULL); ++ bfd_map_over_sections (core_bfd, build_id_addr_candidate, NULL); ++ ++ /* Sections are sorted in the high-to-low VMAs order. ++ Stop the search on the first ELF header we find. ++ Do not continue the search even if it does not contain NT_GNU_BUILD_ID. */ ++ ++ for (candidate = build_id_addr_sect; candidate != NULL; ++ candidate = candidate->next) ++ { ++ i_phdr = elf_get_phdr (core_bfd, ++ bfd_section_vma (candidate->sect), ++ &e_phnum, &loadbase); ++ if (i_phdr != NULL) ++ break; ++ } ++ ++ if (i_phdr != NULL) ++ { ++ retval = build_id_phdr_get (core_bfd, loadbase, e_phnum, i_phdr); ++ xfree (i_phdr); ++ } ++ ++ while (build_id_addr_sect != NULL) ++ { ++ candidate = build_id_addr_sect; ++ build_id_addr_sect = candidate->next; ++ xfree (candidate); ++ } ++ ++ return retval; ++} ++ + /* See build-id.h. */ + + int +@@ -51,7 +450,7 @@ build_id_verify (bfd *abfd, size_t check + const struct bfd_build_id *found; + int retval = 0; + +- found = build_id_bfd_get (abfd); ++ found = build_id_bfd_shdr_get (abfd); + + if (found == NULL) + warning (_("File \"%s\" has no build-id, file skipped"), +@@ -66,56 +465,159 @@ build_id_verify (bfd *abfd, size_t check + return retval; + } + ++static char * ++link_resolve (const char *symlink, int level) ++{ ++ char buf[PATH_MAX + 1], *target, *retval; ++ ssize_t got; ++ ++ if (level > 10) ++ return xstrdup (symlink); ++ ++ got = readlink (symlink, buf, sizeof (buf)); ++ if (got < 0 || got >= sizeof (buf)) ++ return xstrdup (symlink); ++ buf[got] = '\0'; ++ ++ if (IS_ABSOLUTE_PATH (buf)) ++ target = xstrdup (buf); ++ else ++ { ++ const std::string dir (ldirname (symlink)); ++ ++ target = xstrprintf ("%s" ++#ifndef HAVE_DOS_BASED_FILE_SYSTEM ++ "/" ++#else /* HAVE_DOS_BASED_FILE_SYSTEM */ ++ "\\" ++#endif /* HAVE_DOS_BASED_FILE_SYSTEM */ ++ "%s", dir.c_str(), buf); ++ } ++ ++ retval = link_resolve (target, level + 1); ++ xfree (target); ++ return retval; ++} ++ + /* Helper for build_id_to_debug_bfd. LINK is a path to a potential + build-id-based separate debug file, potentially a symlink to the real file. + If the file exists and matches BUILD_ID, return a BFD reference to it. */ + + static gdb_bfd_ref_ptr +-build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, +- const bfd_byte *build_id) ++build_id_to_debug_bfd_1 (const std::string &orig_link, size_t build_id_len, ++ const bfd_byte *build_id, char **link_return) + { ++ gdb_bfd_ref_ptr ret_bfd = {}; ++ std::string ret_link; ++ + if (separate_debug_file_debug) + { +- printf_unfiltered (_(" Trying %s..."), link.c_str ()); ++ printf_unfiltered (_(" Trying %s..."), orig_link.c_str ()); + gdb_flush (gdb_stdout); + } + +- /* lrealpath() is expensive even for the usually non-existent files. */ +- gdb::unique_xmalloc_ptr filename; +- if (access (link.c_str (), F_OK) == 0) +- filename.reset (lrealpath (link.c_str ())); +- +- if (filename == NULL) ++ for (unsigned seqno = 0;; seqno++) + { +- if (separate_debug_file_debug) +- printf_unfiltered (_(" no, unable to compute real path\n")); ++ std::string link = orig_link; + +- return {}; +- } ++ if (seqno > 0) ++ { ++ /* There can be multiple build-id symlinks pointing to real files ++ with the same build-id (such as hard links). Some of the real ++ files may not be installed. */ + +- /* We expect to be silent on the non-existing files. */ +- gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget); ++ string_appendf (link, ".%u", seqno); ++ } + +- if (debug_bfd == NULL) +- { +- if (separate_debug_file_debug) +- printf_unfiltered (_(" no, unable to open.\n")); ++ ret_link = link; ++ ++ struct stat statbuf_trash; ++ ++ /* `access' automatically dereferences LINK. */ ++ if (lstat (link.c_str (), &statbuf_trash) != 0) ++ { ++ /* Stop increasing SEQNO. */ ++ break; ++ } ++ ++ /* lrealpath() is expensive even for the usually non-existent files. */ ++ gdb::unique_xmalloc_ptr filename; ++ ++ if (access (link.c_str (), F_OK) == 0) ++ filename.reset (lrealpath (link.c_str ())); ++ ++ if (filename == NULL) ++ { ++ if (separate_debug_file_debug) ++ printf_unfiltered (_(" no, unable to compute real path\n")); ++ ++ continue; ++ } ++ ++ /* We expect to be silent on the non-existing files. */ ++ gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1); ++ ++ if (debug_bfd == NULL) ++ { ++ if (separate_debug_file_debug) ++ printf_unfiltered (_(" no, unable to open.\n")); + +- return {}; ++ continue; ++ } ++ ++ if (!build_id_verify (debug_bfd.get(), build_id_len, build_id)) ++ { ++ if (separate_debug_file_debug) ++ printf_unfiltered (_(" no, build-id does not match.\n")); ++ ++ continue; ++ } ++ ++ ret_bfd = debug_bfd; ++ break; + } + +- if (!build_id_verify (debug_bfd.get(), build_id_len, build_id)) ++ std::string link_all; ++ ++ if (ret_bfd != NULL) + { + if (separate_debug_file_debug) +- printf_unfiltered (_(" no, build-id does not match.\n")); +- +- return {}; ++ printf_unfiltered (_(" yes!\n")); ++ } ++ else ++ { ++ /* If none of the real files is found report as missing file ++ always the non-.%u-suffixed file. */ ++ std::string link0 = orig_link; ++ ++ /* If the symlink has target request to install the target. ++ BASE-debuginfo.rpm contains the symlink but BASE.rpm may be missing. ++ https://bugzilla.redhat.com/show_bug.cgi?id=981154 */ ++ std::string link0_resolved (link_resolve (link0.c_str (), 0)); ++ ++ if (link_all.empty ()) ++ link_all = link0_resolved; ++ else ++ { ++ /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with ++ its possible use as an argument for installation command. */ ++ link_all += " " + link0_resolved; ++ } + } + +- if (separate_debug_file_debug) +- printf_unfiltered (_(" yes!\n")); ++ if (link_return != NULL) ++ { ++ if (ret_bfd != NULL) ++ { ++ *link_return = xstrdup (ret_link.c_str ()); ++ } ++ else ++ { ++ *link_return = xstrdup (link_all.c_str ()); ++ } ++ } + +- return debug_bfd; ++ return ret_bfd; + } + + /* Common code for finding BFDs of a given build-id. This function +@@ -124,7 +626,7 @@ build_id_to_debug_bfd_1 (const std::stri + + static gdb_bfd_ref_ptr + build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, +- const char *suffix) ++ const char *suffix, char **link_return) + { + /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will + cause "/.build-id/..." lookups. */ +@@ -147,16 +649,17 @@ build_id_to_bfd_suffix (size_t build_id_ + if (size > 0) + { + size--; +- string_appendf (link, "%02x/", (unsigned) *data++); ++ string_appendf (link, "%02x", (unsigned) *data++); + } +- ++ if (size > 0) ++ link += "/"; + while (size-- > 0) + string_appendf (link, "%02x", (unsigned) *data++); + + link += suffix; + + gdb_bfd_ref_ptr debug_bfd +- = build_id_to_debug_bfd_1 (link, build_id_len, build_id); ++ = build_id_to_debug_bfd_1 (link, build_id_len, build_id, link_return); + if (debug_bfd != NULL) + return debug_bfd; + +@@ -170,7 +673,8 @@ build_id_to_bfd_suffix (size_t build_id_ + if (strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) != 0) + { + link = gdb_sysroot + link; +- debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id); ++ debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id, ++ link_return); + if (debug_bfd != NULL) + return debug_bfd; + } +@@ -179,38 +683,208 @@ build_id_to_bfd_suffix (size_t build_id_ + return {}; + } + ++char * ++build_id_to_filename (const struct bfd_build_id *build_id, char **link_return) ++{ ++ gdb_bfd_ref_ptr abfd; ++ char *result; ++ ++ abfd = build_id_to_exec_bfd (build_id->size, build_id->data, link_return); ++ if (abfd == NULL) ++ return NULL; ++ ++ result = xstrdup (bfd_get_filename (abfd.get ())); ++ return result; ++} ++ ++/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages ++ Try to install the hash file ... ++ avoidance. */ ++ ++struct missing_filepair ++ { ++ char *binary; ++ char *debug; ++ char data[1]; ++ }; ++ ++static struct htab *missing_filepair_hash; ++static struct obstack missing_filepair_obstack; ++ ++static void * ++missing_filepair_xcalloc (size_t nmemb, size_t nmemb_size) ++{ ++ void *retval; ++ size_t size = nmemb * nmemb_size; ++ ++ retval = obstack_alloc (&missing_filepair_obstack, size); ++ memset (retval, 0, size); ++ return retval; ++} ++ ++static hashval_t ++missing_filepair_hash_func (const struct missing_filepair *elem) ++{ ++ hashval_t retval = 0; ++ ++ retval ^= htab_hash_string (elem->binary); ++ if (elem->debug != NULL) ++ retval ^= htab_hash_string (elem->debug); ++ ++ return retval; ++} ++ ++static int ++missing_filepair_eq (const struct missing_filepair *elem1, ++ const struct missing_filepair *elem2) ++{ ++ return strcmp (elem1->binary, elem2->binary) == 0 ++ && ((elem1->debug == NULL) == (elem2->debug == NULL)) ++ && (elem1->debug == NULL || strcmp (elem1->debug, elem2->debug) == 0); ++} ++ ++static void ++missing_filepair_change (void) ++{ ++ if (missing_filepair_hash != NULL) ++ { ++ obstack_free (&missing_filepair_obstack, NULL); ++ /* All their memory came just from missing_filepair_OBSTACK. */ ++ missing_filepair_hash = NULL; ++ } ++} ++ ++static void ++debug_print_executable_changed (void) ++{ ++ missing_filepair_change (); ++} ++ ++/* Notify user the file BINARY with (possibly NULL) associated separate debug ++ information file DEBUG is missing. DEBUG may or may not be the build-id ++ file such as would be: ++ /usr/lib/debug/.build-id/dd/b1d2ce632721c47bb9e8679f369e2295ce71be.debug ++ */ ++ ++void ++debug_print_missing (const char *binary, const char *debug) ++{ ++ size_t binary_len0 = strlen (binary) + 1; ++ size_t debug_len0 = debug ? strlen (debug) + 1 : 0; ++ struct missing_filepair missing_filepair_find; ++ struct missing_filepair *missing_filepair; ++ struct missing_filepair **slot; ++ ++ if (build_id_verbose < BUILD_ID_VERBOSE_FILENAMES) ++ return; ++ ++ if (missing_filepair_hash == NULL) ++ { ++ obstack_init (&missing_filepair_obstack); ++ missing_filepair_hash = htab_create_alloc (64, ++ (hashval_t (*) (const void *)) missing_filepair_hash_func, ++ (int (*) (const void *, const void *)) missing_filepair_eq, NULL, ++ missing_filepair_xcalloc, NULL); ++ } ++ ++ /* Use MISSING_FILEPAIR_FIND first instead of calling obstack_alloc with ++ obstack_free in the case of a (rare) match. The problem is ALLOC_F for ++ MISSING_FILEPAIR_HASH allocates from MISSING_FILEPAIR_OBSTACK maintenance ++ structures for MISSING_FILEPAIR_HASH. Calling obstack_free would possibly ++ not to free only MISSING_FILEPAIR but also some such structures (allocated ++ during the htab_find_slot call). */ ++ ++ missing_filepair_find.binary = (char *) binary; ++ missing_filepair_find.debug = (char *) debug; ++ slot = (struct missing_filepair **) htab_find_slot (missing_filepair_hash, ++ &missing_filepair_find, ++ INSERT); ++ ++ /* While it may be still printed duplicitely with the missing debuginfo file ++ * it is due to once printing about the binary file build-id link and once ++ * about the .debug file build-id link as both the build-id symlinks are ++ * located in the debuginfo package. */ ++ ++ if (*slot != NULL) ++ return; ++ ++ missing_filepair = (struct missing_filepair *) obstack_alloc (&missing_filepair_obstack, ++ sizeof (*missing_filepair) - 1 ++ + binary_len0 + debug_len0); ++ missing_filepair->binary = missing_filepair->data; ++ memcpy (missing_filepair->binary, binary, binary_len0); ++ if (debug != NULL) ++ { ++ missing_filepair->debug = missing_filepair->binary + binary_len0; ++ memcpy (missing_filepair->debug, debug, debug_len0); ++ } ++ else ++ missing_filepair->debug = NULL; ++ ++ *slot = missing_filepair; ++ ++ /* We do not collect and flush these messages as each such message ++ already requires its own separate lines. */ ++ ++ fprintf_unfiltered (gdb_stdlog, ++ _("Missing separate debuginfo for %s\n"), binary); ++ if (debug != NULL) ++ fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"), ++ debug); ++} ++ + /* See build-id.h. */ + + gdb_bfd_ref_ptr +-build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) ++build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id, ++ char **link_return) + { +- return build_id_to_bfd_suffix (build_id_len, build_id, ".debug"); ++ return build_id_to_bfd_suffix (build_id_len, build_id, ".debug", ++ link_return); + } + + /* See build-id.h. */ + + gdb_bfd_ref_ptr +-build_id_to_exec_bfd (size_t build_id_len, const bfd_byte *build_id) ++build_id_to_exec_bfd (size_t build_id_len, const bfd_byte *build_id, ++ char **link_return) + { +- return build_id_to_bfd_suffix (build_id_len, build_id, ""); ++ return build_id_to_bfd_suffix (build_id_len, build_id, "", link_return); + } + + /* See build-id.h. */ + + std::string +-find_separate_debug_file_by_buildid (struct objfile *objfile) ++find_separate_debug_file_by_buildid (struct objfile *objfile, ++ gdb::unique_xmalloc_ptr *build_id_filename_return) + { + const struct bfd_build_id *build_id; + +- build_id = build_id_bfd_get (objfile->obfd); ++ if (build_id_filename_return) ++ *build_id_filename_return = NULL; ++ ++ build_id = build_id_bfd_shdr_get (objfile->obfd); + if (build_id != NULL) + { + if (separate_debug_file_debug) + printf_unfiltered (_("\nLooking for separate debug info (build-id) for " + "%s\n"), objfile_name (objfile)); + ++ char *build_id_filename_cstr = NULL; + gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size, +- build_id->data)); ++ build_id->data, ++ (!build_id_filename_return ? NULL : &build_id_filename_cstr))); ++ if (build_id_filename_return) ++ { ++ if (!build_id_filename_cstr) ++ gdb_assert (!*build_id_filename_return); ++ else ++ { ++ *build_id_filename_return = gdb::unique_xmalloc_ptr (build_id_filename_cstr); ++ build_id_filename_cstr = NULL; ++ } ++ } ++ + /* Prevent looping on a stripped .debug file. */ + if (abfd != NULL + && filename_cmp (bfd_get_filename (abfd.get ()), +@@ -223,3 +897,21 @@ find_separate_debug_file_by_buildid (str + + return std::string (); + } ++ ++extern void _initialize_build_id (void); ++ ++void ++_initialize_build_id (void) ++{ ++ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose, ++ _("\ ++Set debugging level of the build-id locator."), _("\ ++Show debugging level of the build-id locator."), _("\ ++Level 1 (default) enables printing the missing debug filenames,\n\ ++level 2 also prints the parsing of binaries to find the identificators."), ++ NULL, ++ show_build_id_verbose, ++ &setlist, &showlist); ++ ++ gdb::observers::executable_changed.attach (debug_print_executable_changed); ++} +diff -Naurp insight-11.0.50.20201205.orig/gdb/build-id.h insight-11.0.50.20201205.new/gdb/build-id.h +--- insight-11.0.50.20201205.orig/gdb/build-id.h 2020-01-03 10:42:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/build-id.h 2020-12-13 19:21:45.204850613 +0100 +@@ -23,9 +23,10 @@ + #include "gdb_bfd.h" + #include "gdbsupport/rsp-low.h" + +-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */ ++/* Separate debuginfo files have corrupted PHDR but SHDR is correct there. ++ Locate NT_GNU_BUILD_ID from ABFD and return its content. */ + +-extern const struct bfd_build_id *build_id_bfd_get (bfd *abfd); ++extern const struct bfd_build_id *build_id_bfd_shdr_get (bfd *abfd); + + /* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value. + Otherwise, issue a warning and return false. */ +@@ -38,21 +39,26 @@ extern int build_id_verify (bfd *abfd, + can be found, return NULL. */ + + extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len, +- const bfd_byte *build_id); ++ const bfd_byte *build_id, ++ char **link_return); ++ ++extern char *build_id_to_filename (const struct bfd_build_id *build_id, ++ char **link_return); + + /* Find and open a BFD for an executable file given a build-id. If no BFD + can be found, return NULL. The returned reference to the BFD must be + released by the caller. */ + + extern gdb_bfd_ref_ptr build_id_to_exec_bfd (size_t build_id_len, +- const bfd_byte *build_id); ++ const bfd_byte *build_id, ++ char **link_return); + + /* Find the separate debug file for OBJFILE, by using the build-id + associated with OBJFILE's BFD. If successful, returns the file name for the + separate debug file, otherwise, return an empty string. */ + +-extern std::string find_separate_debug_file_by_buildid +- (struct objfile *objfile); ++extern std::string find_separate_debug_file_by_buildid (struct objfile *objfile, ++ gdb::unique_xmalloc_ptr *build_id_filename_return); + + /* Return an hex-string representation of BUILD_ID. */ + +diff -Naurp insight-11.0.50.20201205.orig/gdb/coffread.c insight-11.0.50.20201205.new/gdb/coffread.c +--- insight-11.0.50.20201205.orig/gdb/coffread.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/coffread.c 2020-12-13 19:21:45.204850613 +0100 +@@ -709,7 +709,8 @@ coff_symfile_read (struct objfile *objfi + /* Try to add separate debug file if no symbols table found. */ + if (!objfile_has_partial_symbols (objfile)) + { +- std::string debugfile = find_separate_debug_file_by_buildid (objfile); ++ std::string debugfile = find_separate_debug_file_by_buildid (objfile, ++ NULL); + + if (debugfile.empty ()) + debugfile = find_separate_debug_file_by_debuglink (objfile); +diff -Naurp insight-11.0.50.20201205.orig/gdb/corelow.c insight-11.0.50.20201205.new/gdb/corelow.c +--- insight-11.0.50.20201205.orig/gdb/corelow.c 2020-11-20 09:42:30.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/corelow.c 2020-12-13 19:58:39.560059866 +0100 +@@ -22,6 +22,10 @@ + #include + #include + #include "frame.h" /* required by inferior.h */ ++#include "auxv.h" ++#include "build-id.h" ++#include "elf/common.h" ++#include "gdbcmd.h" + #include "inferior.h" + #include "infrun.h" + #include "symtab.h" +@@ -341,6 +345,8 @@ add_to_thread_list (asection *asect, ase + switch_to_thread (thr); /* Yes, make it current. */ + } + ++static bool build_id_core_loads = true; ++ + /* Issue a message saying we have no core to debug, if FROM_TTY. */ + + static void +@@ -377,19 +383,25 @@ core_file_command (const char *filename, + static void + locate_exec_from_corefile_build_id (bfd *abfd, int from_tty) + { +- const bfd_build_id *build_id = build_id_bfd_get (abfd); ++ const bfd_build_id *build_id = build_id_bfd_shdr_get (abfd); + if (build_id == nullptr) + return; + ++ char *build_id_filename; + gdb_bfd_ref_ptr execbfd +- = build_id_to_exec_bfd (build_id->size, build_id->data); ++ = build_id_to_exec_bfd (build_id->size, build_id->data, ++ &build_id_filename); + + if (execbfd != nullptr) + { + exec_file_attach (bfd_get_filename (execbfd.get ()), from_tty); + symbol_file_add_main (bfd_get_filename (execbfd.get ()), + symfile_add_flag (from_tty ? SYMFILE_VERBOSE : 0)); ++ if (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. */ +@@ -1170,4 +1182,11 @@ _initialize_corelow () + maintenance_print_core_file_backed_mappings, + _("Print core file's file-backed mappings."), + &maintenanceprintlist); ++ ++ add_setshow_boolean_cmd ("build-id-core-loads", class_files, ++ &build_id_core_loads, _("\ ++Set whether CORE-FILE loads the build-id associated files automatically."), _("\ ++Show whether CORE-FILE loads the build-id associated files automatically."), ++ NULL, NULL, NULL, ++ &setlist, &showlist); + } +diff -Naurp insight-11.0.50.20201205.orig/gdb/doc/gdb.texinfo insight-11.0.50.20201205.new/gdb/doc/gdb.texinfo +--- insight-11.0.50.20201205.orig/gdb/doc/gdb.texinfo 2020-11-20 09:42:30.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/doc/gdb.texinfo 2020-12-13 19:21:45.210850670 +0100 +@@ -21219,6 +21219,27 @@ information files. + + @end table + ++You can also adjust the current verbosity of the @dfn{build id} locating. ++ ++@table @code ++ ++@kindex set build-id-verbose ++@item set build-id-verbose 0 ++No additional messages are printed. ++ ++@item set build-id-verbose 1 ++Missing separate debug filenames are printed. ++ ++@item set build-id-verbose 2 ++Missing separate debug filenames are printed and also all the parsing of the ++binaries to find their @dfn{build id} content is printed. ++ ++@kindex show build-id-verbose ++@item show build-id-verbose ++Show the current verbosity value for the @dfn{build id} content locating. ++ ++@end table ++ + @cindex @code{.gnu_debuglink} sections + @cindex debug link sections + A debug link is a special section of the executable file named +diff -Naurp insight-11.0.50.20201205.orig/gdb/dwarf2/index-cache.c insight-11.0.50.20201205.new/gdb/dwarf2/index-cache.c +--- insight-11.0.50.20201205.orig/gdb/dwarf2/index-cache.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/dwarf2/index-cache.c 2020-12-13 19:21:45.210850670 +0100 +@@ -95,7 +95,7 @@ index_cache::store (dwarf2_per_objfile * + return; + + /* Get build id of objfile. */ +- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd); ++ const bfd_build_id *build_id = build_id_bfd_shdr_get (obj->obfd); + if (build_id == nullptr) + { + if (debug_index_cache) +@@ -113,7 +113,8 @@ index_cache::store (dwarf2_per_objfile * + + if (dwz != nullptr) + { +- const bfd_build_id *dwz_build_id = build_id_bfd_get (dwz->dwz_bfd.get ()); ++ const bfd_build_id *dwz_build_id ++ = build_id_bfd_shdr_get (dwz->dwz_bfd.get ()); + + if (dwz_build_id == nullptr) + { +diff -Naurp insight-11.0.50.20201205.orig/gdb/dwarf2/read.c insight-11.0.50.20201205.new/gdb/dwarf2/read.c +--- insight-11.0.50.20201205.orig/gdb/dwarf2/read.c 2020-12-13 19:20:06.053900941 +0100 ++++ insight-11.0.50.20201205.new/gdb/dwarf2/read.c 2020-12-13 19:21:45.213850699 +0100 +@@ -2325,7 +2325,7 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per + } + + 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) + { +@@ -6094,7 +6094,7 @@ get_gdb_index_contents_from_section (obj + static gdb::array_view + get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) + { +- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd); ++ const bfd_build_id *build_id = build_id_bfd_shdr_get (obj->obfd); + if (build_id == nullptr) + return {}; + +@@ -6107,7 +6107,7 @@ get_gdb_index_contents_from_cache (objfi + static gdb::array_view + get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz) + { +- const bfd_build_id *build_id = build_id_bfd_get (dwz->dwz_bfd.get ()); ++ const bfd_build_id *build_id = build_id_bfd_shdr_get (dwz->dwz_bfd.get ()); + if (build_id == nullptr) + return {}; + +diff -Naurp insight-11.0.50.20201205.orig/gdb/elfread.c insight-11.0.50.20201205.new/gdb/elfread.c +--- insight-11.0.50.20201205.orig/gdb/elfread.c 2020-11-14 01:10:18.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/elfread.c 2020-12-13 19:21:45.214850708 +0100 +@@ -1303,7 +1303,9 @@ elf_symfile_read (struct objfile *objfil + && objfile->separate_debug_objfile == NULL + && objfile->separate_debug_objfile_backlink == NULL) + { +- std::string debugfile = find_separate_debug_file_by_buildid (objfile); ++ gdb::unique_xmalloc_ptr build_id_filename; ++ std::string debugfile ++ = find_separate_debug_file_by_buildid (objfile, &build_id_filename); + + if (debugfile.empty ()) + debugfile = find_separate_debug_file_by_debuglink (objfile); +@@ -1318,7 +1320,7 @@ elf_symfile_read (struct objfile *objfil + else + { + has_dwarf2 = false; +- const struct bfd_build_id *build_id = build_id_bfd_get (objfile->obfd); ++ const struct bfd_build_id *build_id = build_id_bfd_shdr_get (objfile->obfd); + + if (build_id != nullptr) + { +@@ -1343,6 +1345,10 @@ elf_symfile_read (struct objfile *objfil + has_dwarf2 = true; + } + } ++ /* Check if any separate debug info has been extracted out. */ ++ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") ++ != NULL) ++ debug_print_missing (objfile_name (objfile), build_id_filename.get ()); + } + } + } +diff -Naurp insight-11.0.50.20201205.orig/gdb/exec.c insight-11.0.50.20201205.new/gdb/exec.c +--- insight-11.0.50.20201205.orig/gdb/exec.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/exec.c 2020-12-13 19:21:45.214850708 +0100 +@@ -238,7 +238,7 @@ validate_exec_file (int from_tty) + current_exec_file = get_exec_file (0); + + const bfd_build_id *exec_file_build_id +- = build_id_bfd_get (current_program_space->exec_bfd ()); ++ = build_id_bfd_shdr_get (current_program_space->exec_bfd ()); + if (exec_file_build_id != nullptr) + { + /* Prepend the target prefix, to force gdb_bfd_open to open the +@@ -251,7 +251,7 @@ validate_exec_file (int from_tty) + if (abfd != nullptr) + { + const bfd_build_id *target_exec_file_build_id +- = build_id_bfd_get (abfd.get ()); ++ = build_id_bfd_shdr_get (abfd.get ()); + + if (target_exec_file_build_id != nullptr) + { +diff -Naurp insight-11.0.50.20201205.orig/gdb/objfiles.h insight-11.0.50.20201205.new/gdb/objfiles.h +--- insight-11.0.50.20201205.orig/gdb/objfiles.h 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/objfiles.h 2020-12-13 19:21:45.214850708 +0100 +@@ -711,6 +711,10 @@ public: + bool skip_jit_symbol_lookup = false; + }; + ++/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */ ++ ++#define OBJF_BUILD_ID_CORE_LOADED static_cast(1 << 12) ++ + /* A deleter for objfile. */ + + struct objfile_deleter +diff -Naurp insight-11.0.50.20201205.orig/gdb/python/py-objfile.c insight-11.0.50.20201205.new/gdb/python/py-objfile.c +--- insight-11.0.50.20201205.orig/gdb/python/py-objfile.c 2020-12-05 17:01:34.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/python/py-objfile.c 2020-12-13 19:21:45.214850708 +0100 +@@ -132,7 +132,7 @@ objfpy_get_build_id (PyObject *self, voi + + try + { +- build_id = build_id_bfd_get (objfile->obfd); ++ build_id = build_id_bfd_shdr_get (objfile->obfd); + } + catch (const gdb_exception &except) + { +@@ -600,7 +600,7 @@ objfpy_lookup_objfile_by_build_id (const + /* Don't return separate debug files. */ + if (objfile->separate_debug_objfile_backlink != NULL) + continue; +- obfd_build_id = build_id_bfd_get (objfile->obfd); ++ obfd_build_id = build_id_bfd_shdr_get (objfile->obfd); + if (obfd_build_id == NULL) + continue; + if (objfpy_build_id_matches (obfd_build_id, build_id)) +diff -Naurp insight-11.0.50.20201205.orig/gdb/solib-svr4.c insight-11.0.50.20201205.new/gdb/solib-svr4.c +--- insight-11.0.50.20201205.orig/gdb/solib-svr4.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/solib-svr4.c 2020-12-13 19:59:53.296766123 +0100 +@@ -45,6 +45,7 @@ + #include "auxv.h" + #include "gdb_bfd.h" + #include "probe.h" ++#include "build-id.h" + + static struct link_map_offsets *svr4_fetch_link_map_offsets (void); + static int svr4_have_link_map_offsets (void); +@@ -1343,9 +1344,51 @@ svr4_read_so_list (svr4_info *info, CORE + continue; + } + +- strncpy (newobj->so_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1); +- newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; +- strcpy (newobj->so_original_name, newobj->so_name); ++ { ++ struct bfd_build_id *build_id; ++ ++ strncpy (newobj->so_original_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1); ++ newobj->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; ++ /* May get overwritten below. */ ++ strcpy (newobj->so_name, newobj->so_original_name); ++ ++ build_id = build_id_addr_get (((lm_info_svr4 *) newobj->lm_info)->l_ld); ++ if (build_id != NULL) ++ { ++ char *name, *build_id_filename; ++ ++ /* Missing the build-id matching separate debug info file ++ would be handled while SO_NAME gets loaded. */ ++ name = build_id_to_filename (build_id, &build_id_filename); ++ if (name != NULL) ++ { ++ strncpy (newobj->so_name, name, SO_NAME_MAX_PATH_SIZE - 1); ++ newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; ++ xfree (name); ++ } ++ else ++ { ++ debug_print_missing (newobj->so_name, build_id_filename); ++ ++ /* In the case the main executable was found according to ++ its build-id (from a core file) prevent loading ++ a different build of a library with accidentally the ++ same SO_NAME. ++ ++ It suppresses bogus backtraces (and prints "??" there ++ instead) if the on-disk files no longer match the ++ running program version. */ ++ ++ if (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; ++ } ++ ++ xfree (build_id_filename); ++ xfree (build_id); ++ } ++ } + + /* If this entry has no name, or its name matches the name + for the main executable, don't include it in the list. */ +diff -Naurp insight-11.0.50.20201205.orig/gdb/source.c insight-11.0.50.20201205.new/gdb/source.c +--- insight-11.0.50.20201205.orig/gdb/source.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/source.c 2020-12-13 19:21:45.215850718 +0100 +@@ -1177,7 +1177,7 @@ open_source_file (struct symtab *s) + srcpath += s->filename; + } + +- const struct bfd_build_id *build_id = build_id_bfd_get (ofp->obfd); ++ const struct bfd_build_id *build_id = build_id_bfd_shdr_get (ofp->obfd); + + /* Query debuginfod for the source file. */ + if (build_id != nullptr && !srcpath.empty ()) +diff -Naurp insight-11.0.50.20201205.orig/gdb/symfile.h insight-11.0.50.20201205.new/gdb/symfile.h +--- insight-11.0.50.20201205.orig/gdb/symfile.h 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/symfile.h 2020-12-13 19:21:45.215850718 +0100 +@@ -546,12 +546,18 @@ void expand_symtabs_matching + void map_symbol_filenames (symbol_filename_ftype *fun, void *data, + int need_fullname); + ++ + /* Target-agnostic function to load the sections of an executable into memory. + + ARGS should be in the form "EXECUTABLE [OFFSET]", where OFFSET is an + optional offset to apply to each section. */ + extern void generic_load (const char *args, int from_tty); + ++/* build-id support. */ ++extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); ++extern void debug_print_missing (const char *binary, const char *debug); ++#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") ++ + /* From dwarf2read.c */ + + /* Names for a dwarf2 debugging section. The field NORMAL is the normal +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/corefile.exp insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/corefile.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/corefile.exp 2020-09-16 18:57:43.000000000 +0200 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/corefile.exp 2020-12-13 19:21:45.215850718 +0100 +@@ -343,3 +343,33 @@ gdb_test_multiple "core-file $corefile" + pass $test + } + } ++ ++ ++# Test auto-loading of binary files through build-id from the core file. ++set buildid [build_id_debug_filename_get $binfile] ++set wholetest "binfile found by build-id" ++if {$buildid == ""} { ++ untested "$wholetest (binary has no build-id)" ++} else { ++ gdb_exit ++ gdb_start ++ ++ regsub {\.debug$} $buildid {} buildid ++ set debugdir [standard_output_file ${testfile}-debugdir] ++ file delete -force -- $debugdir ++ file mkdir $debugdir/[file dirname $buildid] ++ file copy $binfile $debugdir/$buildid ++ ++ set test "show debug-file-directory" ++ gdb_test_multiple $test $test { ++ -re "The directory where separate debug symbols are searched for is \"(.*)\"\\.\r\n$gdb_prompt $" { ++ set debugdir_orig $expect_out(1,string) ++ pass $test ++ } ++ } ++ gdb_test_no_output "set debug-file-directory $debugdir:$debugdir_orig" "set debug-file-directory" ++ gdb_test "show build-id-core-loads" {Whether CORE-FILE loads the build-id associated files automatically is on\.} ++ gdb_test "core-file $corefile" "\r\nProgram terminated with .*" "core-file without executable" ++ gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*" ++ pass $wholetest ++} +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/new-ui-pending-input.exp insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/new-ui-pending-input.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.base/new-ui-pending-input.exp 2020-01-03 10:42:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.base/new-ui-pending-input.exp 2020-12-13 19:21:45.216850728 +0100 +@@ -62,6 +62,7 @@ proc test_command_line_new_ui_pending_in + set options "" + append options " -iex \"set height 0\"" + append options " -iex \"set width 0\"" ++ append options " -iex \"set build-id-verbose 0\"" + append options " -iex \"new-ui console $extra_tty_name\"" + append options " -ex \"b $bpline\"" + append options " -ex \"run\"" +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/lib/gdb.exp insight-11.0.50.20201205.new/gdb/testsuite/lib/gdb.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/lib/gdb.exp 2020-12-04 14:07:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/lib/gdb.exp 2020-12-13 19:21:45.216850728 +0100 +@@ -2067,6 +2067,17 @@ proc default_gdb_start { } { + } + } + ++ # Turn off the missing warnings as the testsuite does not expect it. ++ send_gdb "set build-id-verbose 0\n" ++ gdb_expect 10 { ++ -re "$gdb_prompt $" { ++ verbose "Disabled the missing debug infos warnings." 2 ++ } ++ timeout { ++ warning "Could not disable the missing debug infos warnings.." ++ } ++ } ++ + gdb_debug_init + return 0 + } +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/lib/mi-support.exp insight-11.0.50.20201205.new/gdb/testsuite/lib/mi-support.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/lib/mi-support.exp 2020-11-20 09:42:30.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/lib/mi-support.exp 2020-12-13 19:21:45.217850737 +0100 +@@ -325,6 +325,16 @@ proc default_mi_gdb_start { args } { + warning "Couldn't set the width to 0." + } + } ++ # Turn off the missing warnings as the testsuite does not expect it. ++ send_gdb "190-gdb-set build-id-verbose 0\n" ++ gdb_expect 10 { ++ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" { ++ verbose "Disabled the missing debug infos warnings." 2 ++ } ++ timeout { ++ warning "Could not disable the missing debug infos warnings.." ++ } ++ } + + if { $separate_inferior_pty } { + mi_create_inferior_pty diff --git a/insight-11.0-gdb-vla-intel-fortran-vla-strings.patch b/insight-11.0-gdb-vla-intel-fortran-vla-strings.patch new file mode 100644 index 0000000..433cc40 --- /dev/null +++ b/insight-11.0-gdb-vla-intel-fortran-vla-strings.patch @@ -0,0 +1,1028 @@ +diff -Naurp insight-11.0.50.20201205.orig/gdb/c-valprint.c insight-11.0.50.20201205.new/gdb/c-valprint.c +--- insight-11.0.50.20201205.orig/gdb/c-valprint.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/c-valprint.c 2020-12-13 18:03:16.021186347 +0100 +@@ -548,6 +548,28 @@ c_value_print (struct value *val, struct + else + { + /* normal case */ ++ if (type->code () == TYPE_CODE_PTR ++ && 1 == is_dynamic_type (type)) ++ { ++ CORE_ADDR addr; ++ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type))) ++ addr = value_address (val); ++ else ++ addr = value_as_address (val); ++ ++ /* We resolve the target-type only when the ++ pointer is associated. */ ++ if ((addr != 0) ++ && (0 == type_not_associated (type))) ++ TYPE_TARGET_TYPE (type) = ++ resolve_dynamic_type (TYPE_TARGET_TYPE (type), ++ {}, addr); ++ } ++ else ++ { ++ /* Do nothing. References are already resolved from the beginning, ++ only pointers are resolved when we actual need the target. */ ++ } + fprintf_filtered (stream, "("); + type_print (value_type (val), "", stream, -1); + fprintf_filtered (stream, ") "); +diff -Naurp insight-11.0.50.20201205.orig/gdb/dwarf2/read.c insight-11.0.50.20201205.new/gdb/dwarf2/read.c +--- insight-11.0.50.20201205.orig/gdb/dwarf2/read.c 2020-12-04 14:07:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/dwarf2/read.c 2020-12-13 18:50:59.219610291 +0100 +@@ -1585,7 +1585,10 @@ static void read_signatured_type (signat + + static int attr_to_dynamic_prop (const struct attribute *attr, + struct die_info *die, struct dwarf2_cu *cu, +- struct dynamic_prop *prop, struct type *type); ++ struct dynamic_prop *prop, ++ struct type *default_type, ++ const gdb_byte *additional_data, ++ int additional_data_size); + + /* memory allocation interface */ + +@@ -13683,7 +13686,7 @@ read_func_scope (struct die_info *die, s + newobj->static_link + = XOBNEW (&objfile->objfile_obstack, struct dynamic_prop); + attr_to_dynamic_prop (attr, die, cu, newobj->static_link, +- cu->addr_type ()); ++ cu->addr_type (), NULL, 0); + } + + cu->list_in_scope = cu->get_builder ()->get_local_symbols (); +@@ -16148,7 +16151,7 @@ read_structure_type (struct die_info *di + else + { + struct dynamic_prop prop; +- if (attr_to_dynamic_prop (attr, die, cu, &prop, cu->addr_type ())) ++ if (attr_to_dynamic_prop (attr, die, cu, &prop, cu->addr_type (), NULL, 0)) + type->add_dyn_prop (DYN_PROP_BYTE_SIZE, prop); + TYPE_LENGTH (type) = 0; + } +@@ -17102,7 +17105,7 @@ read_array_type (struct die_info *die, s + byte_stride_prop + = (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop)); + stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop, +- prop_type); ++ prop_type, NULL, 0); + if (!stride_ok) + { + complaint (_("unable to read array DW_AT_byte_stride " +@@ -17880,7 +17883,7 @@ read_tag_string_type (struct die_info *d + struct attribute *attr; + struct dynamic_prop prop; + bool length_is_constant = true; +- LONGEST length; ++ ULONGEST length = UINT_MAX; + + /* There are a couple of places where bit sizes might be made use of + when parsing a DW_TAG_string_type, however, no producer that we know +@@ -17901,6 +17904,10 @@ read_tag_string_type (struct die_info *d + } + } + ++ index_type = objfile_type (objfile)->builtin_int; ++ range_type = create_static_range_type (NULL, index_type, 1, length); ++ ++ /* If DW_AT_string_length is defined, the length is stored in memory. */ + attr = dwarf2_attr (die, DW_AT_string_length, cu); + if (attr != nullptr && !attr->form_is_constant ()) + { +@@ -17927,13 +17934,68 @@ read_tag_string_type (struct die_info *d + } + + /* Convert the attribute into a dynamic property. */ +- if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) ++ if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) + length = 1; + else + length_is_constant = false; + } + else if (attr != nullptr) + { ++ if (attr->form_is_block ()) ++ { ++ struct attribute *byte_size, *bit_size; ++ struct dynamic_prop high; ++ ++ byte_size = dwarf2_attr (die, DW_AT_byte_size, cu); ++ bit_size = dwarf2_attr (die, DW_AT_bit_size, cu); ++ ++ /* DW_AT_byte_size should never occur in combination with ++ DW_AT_bit_size. */ ++ if (byte_size != NULL && bit_size != NULL) ++ complaint (_("DW_AT_byte_size AND " ++ "DW_AT_bit_size found together at the same time.")); ++ ++ /* If DW_AT_string_length AND DW_AT_byte_size exist together, ++ DW_AT_byte_size describes the number of bytes that should be read ++ from the length memory location. */ ++ if (byte_size != NULL) ++ { ++ /* Build new dwarf2_locexpr_baton structure with additions to the ++ data attribute, to reflect DWARF specialities to get address ++ sizes. */ ++ const gdb_byte append_ops[] = ++ { ++ /* DW_OP_deref_size: size of an address on the target machine ++ (bytes), where the size will be specified by the next ++ operand. */ ++ DW_OP_deref_size, ++ /* Operand for DW_OP_deref_size. */ ++ (gdb_byte) byte_size->as_unsigned () }; ++ ++ if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type, ++ append_ops, ARRAY_SIZE(append_ops))) ++ complaint (_("Could not parse DW_AT_byte_size")); ++ } ++ else if (bit_size != NULL) ++ complaint (_("DW_AT_string_length AND " ++ "DW_AT_bit_size found but not supported yet.")); ++ /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default ++ is the address size of the target machine. */ ++ else ++ { ++ const gdb_byte append_ops[] = ++ { DW_OP_deref }; ++ ++ if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type, ++ append_ops, ARRAY_SIZE(append_ops))) ++ complaint (_("Could not parse DW_AT_string_length")); ++ } ++ ++ range_type->bounds ()->high = high; ++ } ++ else ++ range_type->bounds ()->high.set_const_val (attr->as_unsigned ()); ++ + /* This DW_AT_string_length just contains the length with no + indirection. There's no need to create a dynamic property in this + case. Pass 0 for the default value as we know it will not be +@@ -17947,6 +18009,14 @@ read_tag_string_type (struct die_info *d + } + else + { ++ /* Check for the DW_AT_byte_size attribute, which represents the length ++ in this case. */ ++ attr = dwarf2_attr (die, DW_AT_byte_size, cu); ++ if (attr) ++ range_type->bounds ()->high.set_const_val (attr->as_unsigned ()); ++ else ++ range_type->bounds ()->high.set_const_val (1); ++ + /* Use 1 as a fallback length if we have nothing else. */ + length = 1; + } +@@ -17961,6 +18031,7 @@ read_tag_string_type (struct die_info *d + low_bound.set_const_val (1); + range_type = create_range_type (NULL, index_type, &low_bound, &prop, 0); + } ++ + char_type = language_string_char_type (cu->language_defn, gdbarch); + type = create_string_type (NULL, char_type, range_type); + +@@ -18668,7 +18739,8 @@ read_base_type (struct die_info *die, st + static int + attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, + struct dwarf2_cu *cu, struct dynamic_prop *prop, +- struct type *default_type) ++ struct type *default_type, ++ const gdb_byte *additional_data, int additional_data_size) + { + struct dwarf2_property_baton *baton; + dwarf2_per_objfile *per_objfile = cu->per_objfile; +@@ -18700,6 +18772,26 @@ attr_to_dynamic_prop (const struct attri + break; + } + ++ if (additional_data != NULL && additional_data_size > 0) ++ { ++ gdb_byte *data; ++ ++ data = (gdb_byte *) obstack_alloc( ++ &cu->per_objfile->objfile->objfile_obstack, ++ block->size + additional_data_size); ++ memcpy (data, block->data, block->size); ++ memcpy (data + block->size, additional_data, ++ additional_data_size); ++ ++ baton->locexpr.data = data; ++ baton->locexpr.size = block->size + additional_data_size; ++ } ++ else ++ { ++ baton->locexpr.data = block->data; ++ baton->locexpr.size = block->size; ++ } ++ + prop->set_locexpr (baton); + gdb_assert (prop->baton () != NULL); + } +@@ -18735,9 +18827,27 @@ attr_to_dynamic_prop (const struct attri + baton->locexpr.per_cu = cu->per_cu; + baton->locexpr.per_objfile = per_objfile; + struct dwarf_block *block = target_attr->as_block (); +- baton->locexpr.size = block->size; +- baton->locexpr.data = block->data; + baton->locexpr.is_reference = true; ++ ++ if (additional_data != NULL && additional_data_size > 0) ++ { ++ gdb_byte *data; ++ ++ data = (gdb_byte *) obstack_alloc (&cu->per_objfile->objfile->objfile_obstack, ++ block->size + additional_data_size); ++ memcpy (data, block->data, block->size); ++ memcpy (data + block->size, ++ additional_data, additional_data_size); ++ ++ baton->locexpr.data = data; ++ baton->locexpr.size = block->size + additional_data_size; ++ } ++ else ++ { ++ baton->locexpr.data = block->data; ++ baton->locexpr.size = block->size; ++ } ++ + prop->set_locexpr (baton); + gdb_assert (prop->baton () != NULL); + } +@@ -18901,8 +19011,8 @@ read_subrange_type (struct die_info *die + } + + attr = dwarf2_attr (die, DW_AT_lower_bound, cu); +- if (attr != nullptr) +- attr_to_dynamic_prop (attr, die, cu, &low, base_type); ++ if (attr) ++ attr_to_dynamic_prop (attr, die, cu, &low, base_type, NULL, 0); + else if (!low_default_is_valid) + complaint (_("Missing DW_AT_lower_bound " + "- DIE at %s [in module %s]"), +@@ -18911,10 +19021,10 @@ read_subrange_type (struct die_info *die + + struct attribute *attr_ub, *attr_count; + attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu); +- if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type)) ++ if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0)) + { + attr = attr_count = dwarf2_attr (die, DW_AT_count, cu); +- if (attr_to_dynamic_prop (attr, die, cu, &high, base_type)) ++ if (attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0)) + { + /* If bounds are constant do the final calculation here. */ + if (low.kind () == PROP_CONST && high.kind () == PROP_CONST) +@@ -18965,7 +19075,7 @@ read_subrange_type (struct die_info *die + { + struct type *prop_type = cu->addr_sized_int_type (false); + attr_to_dynamic_prop (attr_byte_stride, die, cu, &byte_stride_prop, +- prop_type); ++ prop_type, NULL, 0); + } + + struct dynamic_prop bit_stride_prop; +@@ -18985,7 +19095,7 @@ read_subrange_type (struct die_info *die + { + struct type *prop_type = cu->addr_sized_int_type (false); + attr_to_dynamic_prop (attr_bit_stride, die, cu, &bit_stride_prop, +- prop_type); ++ prop_type, NULL, 0); + } + } + +@@ -25063,7 +25173,7 @@ set_die_type (struct die_info *die, stru + if (attr != NULL) + { + struct type *prop_type = cu->addr_sized_int_type (false); +- if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) ++ if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) + type->add_dyn_prop (DYN_PROP_ALLOCATED, prop); + } + +@@ -25072,7 +25182,7 @@ set_die_type (struct die_info *die, stru + if (attr != NULL) + { + struct type *prop_type = cu->addr_sized_int_type (false); +- if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) ++ if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0)) + type->add_dyn_prop (DYN_PROP_ASSOCIATED, prop); + } + +@@ -25080,7 +25190,7 @@ set_die_type (struct die_info *die, stru + if (!skip_data_location) + { + attr = dwarf2_attr (die, DW_AT_data_location, cu); +- if (attr_to_dynamic_prop (attr, die, cu, &prop, cu->addr_type ())) ++ if (attr_to_dynamic_prop (attr, die, cu, &prop, cu->addr_type (), NULL, 0)) + type->add_dyn_prop (DYN_PROP_DATA_LOCATION, prop); + } + +diff -Naurp insight-11.0.50.20201205.orig/gdb/f-typeprint.c insight-11.0.50.20201205.new/gdb/f-typeprint.c +--- insight-11.0.50.20201205.orig/gdb/f-typeprint.c 2020-11-05 01:45:35.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/f-typeprint.c 2020-12-13 18:03:16.025186386 +0100 +@@ -228,7 +228,7 @@ f_language::f_type_print_varspec_suffix + case TYPE_CODE_REF: + f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0, + arrayprint_recurse_level, false); +- fprintf_filtered (stream, " )"); ++ fprintf_filtered (stream, ")"); + break; + + case TYPE_CODE_FUNC: +diff -Naurp insight-11.0.50.20201205.orig/gdb/gdbtypes.c insight-11.0.50.20201205.new/gdb/gdbtypes.c +--- insight-11.0.50.20201205.orig/gdb/gdbtypes.c 2020-12-04 14:07:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/gdbtypes.c 2020-12-13 18:03:16.026186395 +0100 +@@ -1995,7 +1995,8 @@ is_dynamic_type_internal (struct type *t + type = check_typedef (type); + + /* We only want to recognize references at the outermost level. */ +- if (top_level && type->code () == TYPE_CODE_REF) ++ if (top_level && ++ (type->code () == TYPE_CODE_REF || type-> code() == TYPE_CODE_PTR)) + type = check_typedef (TYPE_TARGET_TYPE (type)); + + /* Types that have a dynamic TYPE_DATA_LOCATION are considered +@@ -2035,10 +2036,10 @@ is_dynamic_type_internal (struct type *t + || is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0)); + } + +- case TYPE_CODE_STRING: + /* Strings are very much like an array of characters, and can be + treated as one here. */ + case TYPE_CODE_ARRAY: ++ case TYPE_CODE_STRING: + { + gdb_assert (type->num_fields () == 1); + +@@ -2201,11 +2202,15 @@ resolve_dynamic_array_or_string (struct + + ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type)); + +- if (ary_dim != NULL && ary_dim->code () == TYPE_CODE_ARRAY) ++ if (ary_dim != NULL && (ary_dim->code () == TYPE_CODE_ARRAY ++ || ary_dim->code () == TYPE_CODE_STRING)) + elt_type = resolve_dynamic_array_or_string (ary_dim, addr_stack); + else + elt_type = TYPE_TARGET_TYPE (type); + ++ if (type->code () == TYPE_CODE_STRING) ++ return create_string_type (type, elt_type, range_type); ++ + prop = type->dyn_prop (DYN_PROP_BYTE_STRIDE); + if (prop != NULL) + { +@@ -2551,6 +2556,25 @@ resolve_dynamic_struct (struct type *typ + return resolved_type; + } + ++/* Worker for pointer types. */ ++ ++static struct type * ++resolve_dynamic_pointer (struct type *type, ++ struct property_addr_info *addr_stack) ++{ ++ struct dynamic_prop *prop; ++ CORE_ADDR value; ++ ++ type = copy_type (type); ++ ++ /* Resolve associated property. */ ++ prop = TYPE_ASSOCIATED_PROP (type); ++ if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value)) ++ prop->set_const_val (value); ++ ++ return type; ++} ++ + /* Worker for resolved_dynamic_type. */ + + static struct type * +@@ -2612,6 +2636,9 @@ resolve_dynamic_type_internal (struct ty + case TYPE_CODE_ARRAY: + resolved_type = resolve_dynamic_array_or_string (type, addr_stack); + break; ++ case TYPE_CODE_PTR: ++ resolved_type = resolve_dynamic_pointer (type, addr_stack); ++ break; + + case TYPE_CODE_RANGE: + resolved_type = resolve_dynamic_range (type, addr_stack); +diff -Naurp insight-11.0.50.20201205.orig/gdb/NEWS insight-11.0.50.20201205.new/gdb/NEWS +--- insight-11.0.50.20201205.orig/gdb/NEWS 2020-12-04 14:07:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/NEWS 2020-12-13 18:03:16.020186338 +0100 +@@ -1058,6 +1058,8 @@ SH-5/SH64 running OpenBSD SH-5/SH64 sup + + *** Changes in GDB 8.1 + ++* Fortran: Support pointers to dynamic types. ++ + * GDB now supports dynamically creating arbitrary register groups specified + in XML target descriptions. This allows for finer grain grouping of + registers on systems with a large amount of registers. +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.cp/vla-cxx.cc insight-11.0.50.20201205.new/gdb/testsuite/gdb.cp/vla-cxx.cc +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.cp/vla-cxx.cc 2020-01-03 10:42:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.cp/vla-cxx.cc 2020-12-13 18:03:16.026186395 +0100 +@@ -15,6 +15,10 @@ + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + ++extern "C" { ++#include ++} ++ + struct container; + + struct element +@@ -40,11 +44,16 @@ int main(int argc, char **argv) + typedef typeof (vla) &vlareftypedef; + vlareftypedef vlaref2 (vla); + container c; ++ typeof (vla) *ptr = NULL; ++ ++ // Before pointer assignment ++ ptr = &vla; + + for (int i = 0; i < z; ++i) + vla[i] = 5 + 2 * i; + + // vlas_filled + vla[0] = 2 * vla[0]; ++ + return vla[2]; + } +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.cp/vla-cxx.exp insight-11.0.50.20201205.new/gdb/testsuite/gdb.cp/vla-cxx.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.cp/vla-cxx.exp 2020-01-03 10:42:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.cp/vla-cxx.exp 2020-12-13 18:03:16.026186395 +0100 +@@ -23,6 +23,12 @@ if ![runto_main] { + return -1 + } + ++gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] ++gdb_continue_to_breakpoint "Before pointer assignment" ++gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment" ++gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment" ++gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment" ++ + gdb_breakpoint [gdb_get_line_number "vlas_filled"] + gdb_continue_to_breakpoint "vlas_filled" + +@@ -33,3 +39,6 @@ gdb_test "print vlaref" " = \\(int \\(&\ + # bug being tested, it's better not to depend on the exact spelling. + gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}" + gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}" ++gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]" ++gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex" ++gdb_test "print *ptr" " = \\{5, 7, 9\\}" +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/pointers.exp insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/pointers.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/pointers.exp 1970-01-01 01:00:00.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/pointers.exp 2020-12-13 18:03:16.027186405 +0100 +@@ -0,0 +1,143 @@ ++# Copyright 2016 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++standard_testfile "pointers.f90" ++load_lib fortran.exp ++ ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ ++ {debug f90 quiet}] } { ++ return -1 ++} ++ ++if ![runto_main] { ++ untested "could not run to main" ++ return -1 ++} ++ ++# Depending on the compiler being used, the type names can be printed differently. ++set logical [fortran_logical4] ++set real [fortran_real4] ++set int [fortran_int4] ++set complex [fortran_complex4] ++ ++ ++gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] ++gdb_continue_to_breakpoint "Before pointer assignment" ++gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) 0x0" "print logp, not associated" ++gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated" ++gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) 0x0" "print comp, not associated" ++gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated" ++gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) 0x0" "print charp, not associated" ++gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated" ++gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) 0x0" "print charap, not associated" ++gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated" ++gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" "print intp, not associated" ++gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated" ++set test "print intap, not associated" ++gdb_test_multiple "print intap" $test { ++ -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) \r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re " = \r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) 0x0" "print realp, not associated" ++gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated" ++gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" ++set test "print cyclicp1, not associated" ++gdb_test_multiple "print cyclicp1" $test { ++ -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "= \\( i = -?\\d+, p = \\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++set test "print cyclicp1%p, not associated" ++gdb_test_multiple "print cyclicp1%p" $test { ++ -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) 0x0\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) \r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++ ++gdb_breakpoint [gdb_get_line_number "Before value assignment"] ++gdb_continue_to_breakpoint "Before value assignment" ++gdb_test "print *(twop)%ivla2" "= " ++ ++ ++gdb_breakpoint [gdb_get_line_number "After value assignment"] ++gdb_continue_to_breakpoint "After value assignment" ++gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) $hex\( <.*>\)?" ++gdb_test "print *logp" "= \\.TRUE\\." ++gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) $hex\( <.*>\)?" ++gdb_test "print *comp" "= \\(1,2\\)" ++gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) $hex\( <.*>\)?" ++gdb_test "print *charp" "= 'a'" ++gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\( <.*>\)?" ++gdb_test "print *charap" "= 'abc'" ++gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) $hex\( <.*>\)?" ++gdb_test "print *intp" "= 10" ++set test_name "print intap, associated" ++gdb_test_multiple "print intap" $test_name { ++ -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" { ++ pass $test_name ++ } ++ -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" { ++ gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)" ++ pass $test_name ++ } ++} ++set test_name "print intvlap, associated" ++gdb_test_multiple "print intvlap" $test_name { ++ -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" { ++ pass $test_name ++ } ++ -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" { ++ gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)" ++ pass $test_name ++ } ++} ++gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) $hex\( <.*>\)?" ++gdb_test "print *realp" "= 3\\.14000\\d+" ++gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two\\)\\) $hex\( <.*>\)?" ++gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)" ++set test_name "print arrayOfPtr(3)%p" ++gdb_test_multiple $test_name $test_name { ++ -re "= \\(PTR TO -> \\( Type two\\)\\) \r\n$gdb_prompt $" { ++ pass $test_name ++ } ++ -re "= \\(PTR TO -> \\( Type two\\)\\) 0x0\r\n$gdb_prompt $" { ++ pass $test_name ++ } ++} ++set test_name "print *(arrayOfPtr(3)%p), associated" ++gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name { ++ -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" { ++ pass $test_name ++ } ++ -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" { ++ pass $test_name ++ } ++} ++gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)" ++gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer\\)\\) $hex\( <.*>\)?" ++gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array" ++gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla" ++gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\) \\(\\)\\)\\) $hex " "Print program counter" +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/pointers.f90 insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/pointers.f90 +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/pointers.f90 2020-01-03 10:42:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/pointers.f90 2020-12-13 18:03:16.027186405 +0100 +@@ -20,21 +20,34 @@ program pointers + integer, allocatable :: ivla2 (:, :) + end type two + ++ type :: typeWithPointer ++ integer i ++ type(typeWithPointer), pointer:: p ++ end type typeWithPointer ++ ++ type :: twoPtr ++ type (two), pointer :: p ++ end type twoPtr ++ + logical, target :: logv + complex, target :: comv + character, target :: charv + character (len=3), target :: chara + integer, target :: intv + integer, target, dimension (10,2) :: inta +- real, target :: realv +- type(two), target :: twov ++ integer, target, allocatable, dimension (:) :: intvla ++ real, target :: realv ++ type(two), target :: twov ++ type(twoPtr) :: arrayOfPtr (3) ++ type(typeWithPointer), target:: cyclicp1,cyclicp2 + + logical, pointer :: logp + complex, pointer :: comp +- character, pointer :: charp +- character (len=3), pointer :: charap ++ character, pointer:: charp ++ character (len=3), pointer:: charap + integer, pointer :: intp + integer, pointer, dimension (:,:) :: intap ++ integer, pointer, dimension (:) :: intvlap + real, pointer :: realp + type(two), pointer :: twop + +@@ -44,8 +57,14 @@ program pointers + nullify (charap) + nullify (intp) + nullify (intap) ++ nullify (intvlap) + nullify (realp) + nullify (twop) ++ nullify (arrayOfPtr(1)%p) ++ nullify (arrayOfPtr(2)%p) ++ nullify (arrayOfPtr(3)%p) ++ nullify (cyclicp1%p) ++ nullify (cyclicp2%p) + + logp => logv ! Before pointer assignment + comp => comv +@@ -53,8 +72,14 @@ program pointers + charap => chara + intp => intv + intap => inta ++ intvlap => intvla + realp => realv + twop => twov ++ arrayOfPtr(2)%p => twov ++ cyclicp1%i = 1 ++ cyclicp1%p => cyclicp2 ++ cyclicp2%i = 2 ++ cyclicp2%p => cyclicp1 + + logv = associated(logp) ! Before value assignment + comv = cmplx(1,2) +@@ -63,6 +88,10 @@ program pointers + intv = 10 + inta(:,:) = 1 + inta(3,1) = 3 ++ allocate (intvla(10)) ++ intvla(:) = 2 ++ intvla(4) = 4 ++ intvlap => intvla + realv = 3.14 + + allocate (twov%ivla1(3)) +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/print_type.exp insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/print_type.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/print_type.exp 2020-09-16 18:57:43.000000000 +0200 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/print_type.exp 2020-12-13 18:03:16.027186405 +0100 +@@ -1,5 +1,6 @@ + # Copyright 2019-2020 Free Software Foundation, Inc. + # ++ + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation; either version 3 of the License, or +@@ -42,7 +43,7 @@ set complex [fortran_complex4] + # matches the string TYPE. + proc check_pointer_type { var_name type } { + gdb_test "ptype ${var_name}" \ +- "type = PTR TO -> \\( ${type} \\)" ++ "type = PTR TO -> \\( ${type}\\)" + } + + gdb_breakpoint [gdb_get_line_number "Before pointer assignment"] +@@ -87,7 +88,8 @@ gdb_test "ptype twop" \ + [multi_line "type = PTR TO -> \\( Type two" \ + " $int, allocatable :: ivla1\\(:\\)" \ + " $int, allocatable :: ivla2\\(:,:\\)" \ +- "End Type two \\)"] ++ "End Type two\\)"] ++ + + gdb_breakpoint [gdb_get_line_number "After value assignment"] + gdb_continue_to_breakpoint "After value assignment" +@@ -99,11 +101,11 @@ gdb_test "ptype intv" "type = $int" + gdb_test "ptype inta" "type = $int \\(10,2\\)" + gdb_test "ptype realv" "type = $real" + +-gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)" +-gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)" +-gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)" +-gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)" +-gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)" ++gdb_test "ptype logp" "type = PTR TO -> \\( $logical\\)" ++gdb_test "ptype comp" "type = PTR TO -> \\( $complex\\)" ++gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1\\)" ++gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3\\)" ++gdb_test "ptype intp" "type = PTR TO -> \\( $int\\)" + set test "ptype intap" + gdb_test_multiple $test $test { + -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" { +@@ -113,4 +115,4 @@ gdb_test_multiple $test $test { + pass $test + } + } +-gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)" ++gdb_test "ptype realp" "type = PTR TO -> \\( $real\\)" +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/vla-strings.exp insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/vla-strings.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/vla-strings.exp 1970-01-01 01:00:00.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/vla-strings.exp 2020-12-13 18:03:16.027186405 +0100 +@@ -0,0 +1,103 @@ ++# Copyright 2016 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++standard_testfile ".f90" ++ ++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ ++ {debug f90 quiet}] } { ++ return -1 ++} ++ ++# check that all fortran standard datatypes will be ++# handled correctly when using as VLA's ++ ++if ![runto_main] { ++ untested "could not run to main" ++ return -1 ++} ++ ++gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"] ++gdb_continue_to_breakpoint "var_char-allocated-1" ++set test "whatis var_char first time" ++gdb_test_multiple "whatis var_char" $test { ++ -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "type = character\\*10\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++set test "ptype var_char first time" ++gdb_test_multiple "ptype var_char" $test { ++ -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "type = character\\*10\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++ ++ ++gdb_test "next" "\\d+.*var_char = 'foo'.*" \ ++ "next to allocation status of var_char" ++gdb_test "print l" " = \\.TRUE\\." "print allocation status first time" ++ ++ ++gdb_breakpoint [gdb_get_line_number "var_char-filled-1"] ++gdb_continue_to_breakpoint "var_char-filled-1" ++set test "print var_char, var_char-filled-1" ++gdb_test_multiple "print var_char" $test { ++ -re "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\r\n$gdb_prompt $" { ++ gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1" ++ pass $test ++ } ++ -re "= 'foo'\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++set test "ptype var_char, var_char-filled-1" ++gdb_test_multiple "ptype var_char" $test { ++ -re "type = PTR TO -> \\( character\\*3\\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "type = character\\*3\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)" ++gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)" ++ ++ ++gdb_breakpoint [gdb_get_line_number "var_char-filled-2"] ++gdb_continue_to_breakpoint "var_char-filled-2" ++set test "print var_char, var_char-filled-2" ++gdb_test_multiple "print var_char" $test { ++ -re "= \\(PTR TO -> \\( character\\*6\\)\\) $hex\r\n$gdb_prompt $" { ++ gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2" ++ pass $test ++ } ++ -re "= 'foobar'\r\n$gdb_prompt $" { ++ pass $test ++ } ++} ++set test "ptype var_char, var_char-filled-2" ++gdb_test_multiple "ptype var_char" $test { ++ -re "type = PTR TO -> \\( character\\*6\\)\r\n$gdb_prompt $" { ++ pass $test ++ } ++ -re "type = character\\*6\r\n$gdb_prompt $" { ++ pass $test ++ } ++} +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/vla-strings.f90 insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/vla-strings.f90 +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/vla-strings.f90 1970-01-01 01:00:00.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/vla-strings.f90 2020-12-13 18:03:16.027186405 +0100 +@@ -0,0 +1,39 @@ ++! Copyright 2016 Free Software Foundation, Inc. ++! ++! This program is free software; you can redistribute it and/or modify ++! it under the terms of the GNU General Public License as published by ++! the Free Software Foundation; either version 3 of the License, or ++! (at your option) any later version. ++! ++! This program is distributed in the hope that it will be useful, ++! but WITHOUT ANY WARRANTY; without even the implied warranty of ++! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++! GNU General Public License for more details. ++! ++! You should have received a copy of the GNU General Public License ++! along with this program. If not, see . ++ ++program vla_strings ++ character(len=:), target, allocatable :: var_char ++ character(len=:), pointer :: var_char_p ++ logical :: l ++ ++ allocate(character(len=10) :: var_char) ++ l = allocated(var_char) ! var_char-allocated-1 ++ var_char = 'foo' ++ deallocate(var_char) ! var_char-filled-1 ++ l = allocated(var_char) ! var_char-deallocated ++ allocate(character(len=42) :: var_char) ++ l = allocated(var_char) ++ var_char = 'foobar' ++ var_char = '' ! var_char-filled-2 ++ var_char = 'bar' ! var_char-empty ++ deallocate(var_char) ++ allocate(character(len=21) :: var_char) ++ l = allocated(var_char) ! var_char-allocated-3 ++ var_char = 'johndoe' ++ var_char_p => var_char ++ l = associated(var_char_p) ! var_char_p-associated ++ var_char_p => null() ++ l = associated(var_char_p) ! var_char_p-not-associated ++end program vla_strings +diff -Naurp insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/vla-value.exp insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/vla-value.exp +--- insight-11.0.50.20201205.orig/gdb/testsuite/gdb.fortran/vla-value.exp 2020-09-16 18:57:43.000000000 +0200 ++++ insight-11.0.50.20201205.new/gdb/testsuite/gdb.fortran/vla-value.exp 2020-12-13 18:03:16.027186405 +0100 +@@ -37,7 +37,7 @@ gdb_breakpoint [gdb_get_line_number "vla + gdb_continue_to_breakpoint "vla1-init" + gdb_test "print vla1" " = " "print non-allocated vla1" + gdb_test "print &vla1" \ +- " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\) \\\)\\\) $hex" \ ++ " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\)\\\)\\\) $hex" \ + "print non-allocated &vla1" + gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \ + "print member in non-allocated vla1 (1)" +@@ -58,7 +58,7 @@ with_timeout_factor 15 { + "step over value assignment of vla1" + } + gdb_test "print &vla1" \ +- " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\) \\\)\\\) $hex" \ ++ " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\)\\\)\\\) $hex" \ + "print allocated &vla1" + gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)" + gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)" +@@ -78,7 +78,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" + # Try to access values in undefined pointer to VLA (dangling) + gdb_test "print pvla" " = " "print undefined pvla" + gdb_test "print &pvla" \ +- " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\) \\\)\\\) $hex" \ ++ " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \ + "print non-associated &pvla" + gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \ + "print undefined pvla(1,3,8)" +@@ -87,7 +87,7 @@ gdb_test "print pvla(1, 3, 8)" "no such + gdb_breakpoint [gdb_get_line_number "pvla-associated"] + gdb_continue_to_breakpoint "pvla-associated" + gdb_test "print &pvla" \ +- " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \ ++ " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \ + "print associated &pvla" + gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)" + gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)" +diff -Naurp insight-11.0.50.20201205.orig/gdb/typeprint.c insight-11.0.50.20201205.new/gdb/typeprint.c +--- insight-11.0.50.20201205.orig/gdb/typeprint.c 2020-12-04 14:07:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/typeprint.c 2020-12-13 18:03:16.027186405 +0100 +@@ -558,6 +558,25 @@ whatis_exp (const char *exp, int show) + printf_filtered (" */\n"); + } + ++ /* Resolve any dynamic target type, as we might print ++ additional information about the target. ++ For example, in Fortran and C we are printing the dimension of the ++ dynamic array the pointer is pointing to. */ ++ if (type->code () == TYPE_CODE_PTR ++ && is_dynamic_type (type) == 1) ++ { ++ CORE_ADDR addr; ++ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type))) ++ addr = value_address (val); ++ else ++ addr = value_as_address (val); ++ ++ if (addr != 0 ++ && type_not_associated (type) == 0) ++ TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type), ++ {}, addr); ++ } ++ + LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags); + printf_filtered ("\n"); + } +diff -Naurp insight-11.0.50.20201205.orig/gdb/valops.c insight-11.0.50.20201205.new/gdb/valops.c +--- insight-11.0.50.20201205.orig/gdb/valops.c 2020-12-04 14:07:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/valops.c 2020-12-13 18:03:16.028186414 +0100 +@@ -1627,6 +1627,19 @@ value_ind (struct value *arg1) + if (base_type->code () == TYPE_CODE_PTR) + { + struct type *enc_type; ++ CORE_ADDR addr; ++ ++ if (type_not_associated (base_type)) ++ error (_("Attempt to take contents of a not associated pointer.")); ++ ++ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type))) ++ addr = value_address (arg1); ++ else ++ addr = value_as_address (arg1); ++ ++ if (addr != 0) ++ TYPE_TARGET_TYPE (base_type) = ++ resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), {}, addr); + + /* We may be pointing to something embedded in a larger object. + Get the real type of the enclosing object. */ +@@ -1644,8 +1657,7 @@ value_ind (struct value *arg1) + else + { + /* Retrieve the enclosing object pointed to. */ +- base_addr = (value_as_address (arg1) +- - value_pointed_to_offset (arg1)); ++ base_addr = (addr - value_pointed_to_offset (arg1)); + } + arg2 = value_at_lazy (enc_type, base_addr); + enc_type = value_type (arg2); +diff -Naurp insight-11.0.50.20201205.orig/gdb/valprint.c insight-11.0.50.20201205.new/gdb/valprint.c +--- insight-11.0.50.20201205.orig/gdb/valprint.c 2020-12-04 14:07:10.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/valprint.c 2020-12-13 18:03:16.028186414 +0100 +@@ -1097,12 +1097,6 @@ value_check_printable (struct value *val + return 0; + } + +- if (type_not_associated (value_type (val))) +- { +- val_print_not_associated (stream); +- return 0; +- } +- + if (type_not_allocated (value_type (val))) + { + val_print_not_allocated (stream); diff --git a/insight-11.0.50-relocate.patch b/insight-11.0.50-relocate.patch new file mode 100644 index 0000000..0dfc04b --- /dev/null +++ b/insight-11.0.50-relocate.patch @@ -0,0 +1,228 @@ +diff -Naurp insight-11.0.50.20201205.orig/gdb/gdbtk/generic/gdbtk.c insight-11.0.50.20201205.new/gdb/gdbtk/generic/gdbtk.c +--- insight-11.0.50.20201205.orig/gdb/gdbtk/generic/gdbtk.c 2020-10-07 15:31:22.000000000 +0200 ++++ insight-11.0.50.20201205.new/gdb/gdbtk/generic/gdbtk.c 2020-12-05 18:02:44.651493530 +0100 +@@ -835,7 +835,7 @@ gdbtk_init (gdbtk_interp *interp) + { + static char set_gdbtk_library_script[] = "\ + if {![info exists env(GDBTK_LIBRARY)]} {\n\ +- set env(GDBTK_LIBRARY) [file join [file dirname [file dirname $Paths(guidir)]] insight1.0]\n\ ++ set env(GDBTK_LIBRARY) [file join [file dirname [file dirname $Paths(guidir)]] insight]\n\ + }\n"; + + command_obj = Tcl_NewStringObj (set_gdbtk_library_script, -1); +@@ -922,7 +922,7 @@ gdbtk_source_start_file (gdbtk_interp *i + proc gdbtk_find_main {} {\n\ + global Paths GDBTK_LIBRARY\n\ + rename gdbtk_find_main {}\n\ +- tcl_findLibrary insight 1.0 {} main.tcl GDBTK_LIBRARY GDBTKLIBRARY\n\ ++ tcl_findLibrary insight {} {} main.tcl GDBTK_LIBRARY GDBTKLIBRARY\n\ + set Paths(appdir) $GDBTK_LIBRARY\n\ + }\n\ + gdbtk_find_main"; +@@ -938,7 +938,7 @@ proc gdbtk_find_main {} {\n\ + } else {\n\ + set debug_startup 0\n\ + }\n\ +- tcl_findLibrary insight 1.0 {} main.tcl GDBTK_LIBRARY GDBTK_LIBRARY\n\ ++ tcl_findLibrary insight {} {} main.tcl GDBTK_LIBRARY GDBTK_LIBRARY\n\ + set Paths(appdir) $GDBTK_LIBRARY\n\ + }\n\ + gdbtk_find_main"; +diff -Naurp insight-11.0.50.20201205.orig/gdb/gdbtk/library/main.tcl insight-11.0.50.20201205.new/gdb/gdbtk/library/main.tcl +--- insight-11.0.50.20201205.orig/gdb/gdbtk/library/main.tcl 2020-07-24 13:04:01.000000000 +0200 ++++ insight-11.0.50.20201205.new/gdb/gdbtk/library/main.tcl 2020-12-05 18:02:44.651493530 +0100 +@@ -38,9 +38,15 @@ if {[info exists auto_path]} { + lappend auto_path $GDBTK_LIBRARY + } + +- # Add default plugins directory, which will be [name of exe]/../../lib/insight1.0 ++ # Add default plugins directory, which will be [name of exe]/../../lib/insight + set exename [info nameofexecutable] +- set dir [file join [file dirname [file dirname $exename]] lib insight1.0] ++ set dir [file join [file dirname [file dirname $exename]] lib insight] ++ if {[file exists $dir]} { ++ lappend gdb_plugins $dir ++ lappend auto_path $dir ++ } ++ # Add extra plugins directory, which will be [name of exe]/../../share/insight ++ set dir [file join [file dirname [file dirname $exename]] share insight] + if {[file exists $dir]} { + lappend gdb_plugins $dir + lappend auto_path $dir +diff -Naurp insight-11.0.50.20201205.orig/gdb/gdbtk/plugins/HOW-TO insight-11.0.50.20201205.new/gdb/gdbtk/plugins/HOW-TO +--- insight-11.0.50.20201205.orig/gdb/gdbtk/plugins/HOW-TO 2017-04-30 18:06:42.000000000 +0200 ++++ insight-11.0.50.20201205.new/gdb/gdbtk/plugins/HOW-TO 2020-12-05 18:02:44.652493540 +0100 +@@ -81,7 +81,7 @@ Custom plug-ins are provided as "package + be loaded. + + ** FIXME: don't need to create the directory -- install will do it ** +-i) First, locate the $(EXEC-PREFIX)/lib/insight1.0 directory. This is the ++i) First, locate the $(EXEC-PREFIX)/lib/insight directory. This is the + directory which contains the plug-in code used by Insight. Create a + this directory if it does not exist yet (i.e., if your plug-in + is the first to be installed). +@@ -92,7 +92,7 @@ to that directory. Make sure you have a + auto_mkindex to create it. For instance, in the sample case we would + have: + +- $(EXEC-PREFIX)/lib/insight1.0/rhabout ++ $(EXEC-PREFIX)/lib/insight/rhabout + + ** FIXME: this shows unix. show cygwin, too. ** + and it would contain: +@@ -133,7 +133,7 @@ command with the "-direct" option. + ** FIXME: install will do this, too. ALL plugins should be mentioned + in the global plugins.tcl file ** + v) Create/append the file "plugins.tcl" in the plugins directory +-($(EXEC-PREFIX/lib/insight1.0) if it does not yet exist. This is a file ++($(EXEC-PREFIX/lib/insight) if it does not yet exist. This is a file + shared by all plug-ins so make sure your install script does not overwrite, + but append to it. + +diff -Naurp insight-11.0.50.20201205.orig/gdb/gdbtk/plugins/Make-rules insight-11.0.50.20201205.new/gdb/gdbtk/plugins/Make-rules +--- insight-11.0.50.20201205.orig/gdb/gdbtk/plugins/Make-rules 2017-04-30 18:06:42.000000000 +0200 ++++ insight-11.0.50.20201205.new/gdb/gdbtk/plugins/Make-rules 2020-12-05 18:02:44.652493540 +0100 +@@ -104,12 +104,12 @@ all: $(ALL_TARGETS) + install: $(INSTALL_TARGET) + + install-generic: +- $(mkinstalldirs) $(libdir)/insight1.0/$(PLUGIN) ++ $(mkinstalldirs) $(libdir)/insight/$(PLUGIN) + for i in $(ALL_INSTALL); do \ +- $(INSTALL_DATA) $$i $(libdir)/insight1.0/$(PLUGIN)/$$i ; \ ++ $(INSTALL_DATA) $$i $(libdir)/insight/$(PLUGIN)/$$i ; \ + done ; + for i in pkgIndex.tcl tclIndex $(PLUGIN_INSTALL_SRCDIR) ; do \ +- $(INSTALL_DATA) $(srcdir)/$$i $(libdir)/insight1.0/$(PLUGIN)/$$i ; \ ++ $(INSTALL_DATA) $(srcdir)/$$i $(libdir)/insight/$(PLUGIN)/$$i ; \ + done ; + + html: +diff -Naurp insight-11.0.50.20201205.orig/gdb/gdbtk/README insight-11.0.50.20201205.new/gdb/gdbtk/README +--- insight-11.0.50.20201205.orig/gdb/gdbtk/README 2017-04-30 18:06:42.000000000 +0200 ++++ insight-11.0.50.20201205.new/gdb/gdbtk/README 2020-12-05 18:02:44.652493540 +0100 +@@ -132,7 +132,7 @@ without recompiling. + To make more serious changes to the interface, such as adding a new window or + changing the framework, you will have to hack the tcl code (and probably the C + code as well). The tcl library install directory is $(libdir) (probably +-/usr/local/lib/insight1.0). But, you will probably want to hack on your own ++/usr/local/lib/insight). But, you will probably want to hack on your own + private copy before putting it up for the rest of the users. To find the GDB tcl + code, GDB first checks for the environment variable GDBTK_LIBRARY. GDB will check + this directory for the file "main.tcl". If GDBTK_LIBRARY is not set, GDB will +diff -Naurp insight-11.0.50.20201205.orig/gdb/Makefile.in insight-11.0.50.20201205.new/gdb/Makefile.in +--- insight-11.0.50.20201205.orig/gdb/Makefile.in 2020-12-05 17:05:30.000000000 +0100 ++++ insight-11.0.50.20201205.new/gdb/Makefile.in 2020-12-05 18:02:44.652493540 +0100 +@@ -525,7 +525,7 @@ ALL_TCL_CFLAGS = $(TCL_CFLAGS) $(TK_CFLA + # The version of gdbtk we're building. This should be kept + # in sync with GDBTK_VERSION and friends in gdbtk.h. + GDBTK_VERSION = 1.0 +-GDBTK_LIBRARY = $(datadir)/insight$(GDBTK_VERSION) ++GDBTK_LIBRARY = $(datadir)/insight + + # Gdbtk requires an absolute path to the source directory or + # the testsuite won't run properly. +@@ -2488,10 +2488,11 @@ install-gdbtk: + $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \ + $(SHELL) $(srcdir)/../mkinstalldirs \ + $(DESTDIR)$(GDBTK_LIBRARY) ; \ ++ # Use alternate directory. + $(SHELL) $(srcdir)/../mkinstalldirs \ +- $(DESTDIR)$(libdir)/insight$(GDBTK_VERSION) ; \ ++ $(DESTDIR)$(datadir)/insight ; \ + $(INSTALL_DATA) $(srcdir)/gdbtk/plugins/plugins.tcl \ +- $(DESTDIR)$(libdir)/insight$(GDBTK_VERSION)/plugins.tcl ; \ ++ $(DESTDIR)$(datadir)/insight/plugins.tcl ; \ + $(SHELL) $(srcdir)/../mkinstalldirs \ + $(DESTDIR)$(GDBTK_LIBRARY)/images \ + $(DESTDIR)$(GDBTK_LIBRARY)/images2 ; \ +diff -Naurp insight-11.0.50.20201205.orig/libgui/library/Makefile.am insight-11.0.50.20201205.new/libgui/library/Makefile.am +--- insight-11.0.50.20201205.orig/libgui/library/Makefile.am 2020-07-24 13:01:04.000000000 +0200 ++++ insight-11.0.50.20201205.new/libgui/library/Makefile.am 2020-12-05 18:02:44.653493549 +0100 +@@ -12,7 +12,7 @@ ulset.tcl wframe.tcl wingrab.tcl ventry. + pane.tcl panedwindow.tcl + + ## This directory is also referenced in paths.c, which see. +-guidir = $(datadir)/redhat/gui ++guidir = $(datadir)/insight/gui + gui_DATA = tclIndex pkgIndex.tcl $(TCL) $(PACKAGES) + + +diff -Naurp insight-11.0.50.20201205.orig/libgui/src/Makefile.am insight-11.0.50.20201205.new/libgui/src/Makefile.am +--- insight-11.0.50.20201205.orig/libgui/src/Makefile.am 2017-04-30 18:06:42.000000000 +0200 ++++ insight-11.0.50.20201205.new/libgui/src/Makefile.am 2020-12-05 18:02:44.653493549 +0100 +@@ -12,7 +12,7 @@ include_HEADERS = \ + endif + + datadir = @datadir@ +-guidir = $(datadir)/redhat/gui ++guidir = $(datadir)/insight/gui + + # tkTable version info + include $(srcdir)/tkTable_version.in +diff -Naurp insight-11.0.50.20201205.orig/libgui/src/paths.c insight-11.0.50.20201205.new/libgui/src/paths.c +--- insight-11.0.50.20201205.orig/libgui/src/paths.c 2017-04-30 18:06:42.000000000 +0200 ++++ insight-11.0.50.20201205.new/libgui/src/paths.c 2020-12-05 18:02:44.653493549 +0100 +@@ -13,13 +13,13 @@ + + We first look for the gui library. This can be set by the + REDHAT_GUI_LIBRARY environment variable. Otherwise, it is named +- gui, and is found in $prefix/share/redhat, where $prefix is ++ gui, and is found in $prefix/share/insight, where $prefix is + determined by looking at the directory where the running executable + is installed. + + We then look for the ide library. This can be set by the + REDHAT_IDE_LIBRARY environment variable. Otherwise, it is named +- ide, and is also found in $prefix/share/redhat. ++ ide, and is also found in $prefix/share/insight. + + It is OK if only one of these libraries exist. If neither exists, + we report an error. +@@ -36,7 +36,7 @@ + bitmapdir -- see below + + Paths(appdir) is set based on the ide_initialize_paths APPNAME +- parameter. If a directory $prefix/share/redhat/APPNAME exists, we ++ parameter. If a directory $prefix/share/insight/APPNAME exists, we + set Paths(appdir) to it. More precisely, we set Paths(appdir) if + an APPNAME directory exists which is a sibling directory of the gui + or ide directory. For convenience of some tools, we also check for +@@ -69,13 +69,13 @@ proc initialize_paths {} {\n\ + # Handle build with --exec-prefix and build without.\n\ + set d [file join [file dirname [pwd]] usr share]\n\ + lappend prefdirs $d\n\ +- lappend guidirs [file join $d redhat gui]\n\ ++ lappend guidirs [file join $d insight gui]\n\ + set d [file join [file dirname [pwd]] share]\n\ + lappend prefdirs $d\n\ +- lappend guidirs [file join $d redhat gui]\n\ ++ lappend guidirs [file join $d insight gui]\n\ + set d [file join [file dirname [file dirname [pwd]]] share]\n\ + lappend prefdirs $d\n\ +- lappend guidirs [file join $d redhat gui]\n\ ++ lappend guidirs [file join $d insight gui]\n\ + set Paths(bindir) [pwd]\n\ + # Base `prefix' on where the `share' dir is found\n\ + foreach sd $prefdirs {\n\ +@@ -110,7 +110,7 @@ proc initialize_paths {} {\n\ + lappend idedirs $env(REDHAT_IDE_LIBRARY)\n\ + }\n\ + foreach d $prefdirs {\n\ +- lappend idedirs [file join $d redhat ide]\n\ ++ lappend idedirs [file join $d insight ide]\n\ + }\n\ + # Try to handle running from the build tree:\n\ + lappend idedirs [file join [file dirname [file dirname $::tcl_library]] libide library]\n\ +@@ -180,9 +180,9 @@ proc initialize_paths {} {\n\ + set here [pwd]\n\ + cd [file dirname [info nameofexecutable]]\n\ + set d [file join [file dirname [pwd]] share]\n\ +- lappend guidirs [file join $d redhat gui]\n\ ++ lappend guidirs [file join $d insight gui]\n\ + set d [file join [file dirname [file dirname [pwd]]] share]\n\ +- lappend guidirs [file join $d redhat gui]\n\ ++ lappend guidirs [file join $d insight gui]\n\ + lappend guidirs [file join [file dirname [file dirname $tcl_library]] libgui library]\n\ + foreach sd $guidirs {\n\ + if {[file exists [file join $sd tclIndex]]} {\n\ diff --git a/insight-7.4.50-relocate.patch b/insight-7.4.50-relocate.patch deleted file mode 100644 index 1a644fe..0000000 --- a/insight-7.4.50-relocate.patch +++ /dev/null @@ -1,228 +0,0 @@ -diff -Naur insight-7.4.50.orig/gdb/gdbtk/generic/gdbtk.c insight-7.4.50.new/gdb/gdbtk/generic/gdbtk.c ---- insight-7.4.50.orig/gdb/gdbtk/generic/gdbtk.c 2012-03-30 09:04:59.000000000 +0200 -+++ insight-7.4.50.new/gdb/gdbtk/generic/gdbtk.c 2012-04-03 13:55:00.342592443 +0200 -@@ -512,7 +512,7 @@ - { - static char set_gdbtk_library_script[] = "\ - if {![info exists env(GDBTK_LIBRARY)]} {\n\ -- set env(GDBTK_LIBRARY) [file join [file dirname [file dirname $Paths(guidir)]] insight1.0]\n\ -+ set env(GDBTK_LIBRARY) [file join [file dirname [file dirname $Paths(guidir)]] insight]\n\ - }\n"; - - command_obj = Tcl_NewStringObj (set_gdbtk_library_script, -1); -@@ -598,7 +598,7 @@ - proc gdbtk_find_main {} {\n\ - global Paths GDBTK_LIBRARY\n\ - rename gdbtk_find_main {}\n\ -- tcl_findLibrary insight 1.0 {} main.tcl GDBTK_LIBRARY GDBTKLIBRARY\n\ -+ tcl_findLibrary insight {} {} main.tcl GDBTK_LIBRARY GDBTKLIBRARY\n\ - set Paths(appdir) $GDBTK_LIBRARY\n\ - }\n\ - gdbtk_find_main"; -@@ -614,7 +614,7 @@ - } else {\n\ - set debug_startup 0\n\ - }\n\ -- tcl_findLibrary insight 1.0 {} main.tcl GDBTK_LIBRARY GDBTK_LIBRARY\n\ -+ tcl_findLibrary insight {} {} main.tcl GDBTK_LIBRARY GDBTK_LIBRARY\n\ - set Paths(appdir) $GDBTK_LIBRARY\n\ - }\n\ - gdbtk_find_main"; -diff -Naur insight-7.4.50.orig/gdb/gdbtk/library/main.tcl insight-7.4.50.new/gdb/gdbtk/library/main.tcl ---- insight-7.4.50.orig/gdb/gdbtk/library/main.tcl 2008-08-03 00:08:32.000000000 +0200 -+++ insight-7.4.50.new/gdb/gdbtk/library/main.tcl 2012-04-03 13:50:55.375399743 +0200 -@@ -38,9 +38,15 @@ - lappend auto_path $GDBTK_LIBRARY - } - -- # Add default plugins directory, which will be [name of exe]/../../lib/insight1.0 -+ # Add default plugins directory, which will be [name of exe]/../../lib/insight - set exename [info nameofexecutable] -- set dir [file join [file dirname [file dirname $exename]] lib insight1.0] -+ set dir [file join [file dirname [file dirname $exename]] lib insight] -+ if {[file exists $dir]} { -+ lappend gdb_plugins $dir -+ lappend auto_path $dir -+ } -+ # Add extra plugins directory, which will be [name of exe]/../../share/insight -+ set dir [file join [file dirname [file dirname $exename]] share insight] - if {[file exists $dir]} { - lappend gdb_plugins $dir - lappend auto_path $dir -diff -Naur insight-7.4.50.orig/gdb/gdbtk/plugins/HOW-TO insight-7.4.50.new/gdb/gdbtk/plugins/HOW-TO ---- insight-7.4.50.orig/gdb/gdbtk/plugins/HOW-TO 2002-08-14 20:06:06.000000000 +0200 -+++ insight-7.4.50.new/gdb/gdbtk/plugins/HOW-TO 2012-04-03 13:50:55.375399743 +0200 -@@ -81,7 +81,7 @@ - be loaded. - - ** FIXME: don't need to create the directory -- install will do it ** --i) First, locate the $(EXEC-PREFIX)/lib/insight1.0 directory. This is the -+i) First, locate the $(EXEC-PREFIX)/lib/insight directory. This is the - directory which contains the plug-in code used by Insight. Create a - this directory if it does not exist yet (i.e., if your plug-in - is the first to be installed). -@@ -92,7 +92,7 @@ - auto_mkindex to create it. For instance, in the sample case we would - have: - -- $(EXEC-PREFIX)/lib/insight1.0/rhabout -+ $(EXEC-PREFIX)/lib/insight/rhabout - - ** FIXME: this shows unix. show cygwin, too. ** - and it would contain: -@@ -133,7 +133,7 @@ - ** FIXME: install will do this, too. ALL plugins should be mentioned - in the global plugins.tcl file ** - v) Create/append the file "plugins.tcl" in the plugins directory --($(EXEC-PREFIX/lib/insight1.0) if it does not yet exist. This is a file -+($(EXEC-PREFIX/lib/insight) if it does not yet exist. This is a file - shared by all plug-ins so make sure your install script does not overwrite, - but append to it. - -diff -Naur insight-7.4.50.orig/gdb/gdbtk/plugins/Make-rules insight-7.4.50.new/gdb/gdbtk/plugins/Make-rules ---- insight-7.4.50.orig/gdb/gdbtk/plugins/Make-rules 2008-08-03 00:08:32.000000000 +0200 -+++ insight-7.4.50.new/gdb/gdbtk/plugins/Make-rules 2012-04-03 13:50:55.375399743 +0200 -@@ -104,12 +104,12 @@ - install: $(INSTALL_TARGET) - - install-generic: -- $(mkinstalldirs) $(libdir)/insight1.0/$(PLUGIN) -+ $(mkinstalldirs) $(libdir)/insight/$(PLUGIN) - for i in $(ALL_INSTALL); do \ -- $(INSTALL_DATA) $$i $(libdir)/insight1.0/$(PLUGIN)/$$i ; \ -+ $(INSTALL_DATA) $$i $(libdir)/insight/$(PLUGIN)/$$i ; \ - done ; - for i in pkgIndex.tcl tclIndex $(PLUGIN_INSTALL_SRCDIR) ; do \ -- $(INSTALL_DATA) $(srcdir)/$$i $(libdir)/insight1.0/$(PLUGIN)/$$i ; \ -+ $(INSTALL_DATA) $(srcdir)/$$i $(libdir)/insight/$(PLUGIN)/$$i ; \ - done ; - - html: -diff -Naur insight-7.4.50.orig/gdb/gdbtk/README insight-7.4.50.new/gdb/gdbtk/README ---- insight-7.4.50.orig/gdb/gdbtk/README 2009-11-09 20:31:57.000000000 +0100 -+++ insight-7.4.50.new/gdb/gdbtk/README 2012-04-03 13:50:55.376399710 +0200 -@@ -132,7 +132,7 @@ - To make more serious changes to the interface, such as adding a new window or - changing the framework, you will have to hack the tcl code (and probably the C - code as well). The tcl library install directory is $(libdir) (probably --/usr/local/lib/insight1.0). But, you will probably want to hack on your own -+/usr/local/lib/insight). But, you will probably want to hack on your own - private copy before putting it up for the rest of the users. To find the GDB tcl - code, GDB first checks for the environment variable GDBTK_LIBRARY. GDB will check - this directory for the file "main.tcl". If GDBTK_LIBRARY is not set, GDB will -diff -Naur insight-7.4.50.orig/gdb/Makefile.in insight-7.4.50.new/gdb/Makefile.in ---- insight-7.4.50.orig/gdb/Makefile.in 2012-03-28 23:31:18.000000000 +0200 -+++ insight-7.4.50.new/gdb/Makefile.in 2012-04-03 13:50:55.376399710 +0200 -@@ -376,7 +376,7 @@ - # The version of gdbtk we're building. This should be kept - # in sync with GDBTK_VERSION and friends in gdbtk.h. - GDBTK_VERSION = 1.0 --GDBTK_LIBRARY = $(datadir)/insight$(GDBTK_VERSION) -+GDBTK_LIBRARY = $(datadir)/insight - - # Gdbtk requires an absolute path to the source directory or - # the testsuite won't run properly. -@@ -1738,10 +1738,11 @@ - $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) ; \ - $(SHELL) $(srcdir)/../mkinstalldirs \ - $(DESTDIR)$(GDBTK_LIBRARY) ; \ -+ # Use alternate directory. - $(SHELL) $(srcdir)/../mkinstalldirs \ -- $(DESTDIR)$(libdir)/insight$(GDBTK_VERSION) ; \ -+ $(DESTDIR)$(datadir)/insight ; \ - $(INSTALL_DATA) $(srcdir)/gdbtk/plugins/plugins.tcl \ -- $(DESTDIR)$(libdir)/insight$(GDBTK_VERSION)/plugins.tcl ; \ -+ $(DESTDIR)$(datadir)/insight/plugins.tcl ; \ - $(SHELL) $(srcdir)/../mkinstalldirs \ - $(DESTDIR)$(GDBTK_LIBRARY)/images \ - $(DESTDIR)$(GDBTK_LIBRARY)/images2 ; \ -diff -Naur insight-7.4.50.orig/libgui/library/Makefile.am insight-7.4.50.new/libgui/library/Makefile.am ---- insight-7.4.50.orig/libgui/library/Makefile.am 2012-03-30 11:58:59.000000000 +0200 -+++ insight-7.4.50.new/libgui/library/Makefile.am 2012-04-03 13:50:55.377399680 +0200 -@@ -12,7 +12,7 @@ - pane.tcl panedwindow.tcl - - ## This directory is also referenced in paths.c, which see. --guidir = $(datadir)/redhat/gui -+guidir = $(datadir)/insight/gui - gui_DATA = tclIndex pkgIndex.tcl $(TCL) $(PACKAGES) - - -diff -Naur insight-7.4.50.orig/libgui/src/Makefile.am insight-7.4.50.new/libgui/src/Makefile.am ---- insight-7.4.50.orig/libgui/src/Makefile.am 2008-07-22 22:11:35.000000000 +0200 -+++ insight-7.4.50.new/libgui/src/Makefile.am 2012-04-03 13:50:55.377399680 +0200 -@@ -12,7 +12,7 @@ - endif - - datadir = @datadir@ --guidir = $(datadir)/redhat/gui -+guidir = $(datadir)/insight/gui - - # tkTable version info - include $(srcdir)/tkTable_version.in -diff -Naur insight-7.4.50.orig/libgui/src/paths.c insight-7.4.50.new/libgui/src/paths.c ---- insight-7.4.50.orig/libgui/src/paths.c 2008-07-22 22:11:35.000000000 +0200 -+++ insight-7.4.50.new/libgui/src/paths.c 2012-04-03 13:50:55.377399680 +0200 -@@ -13,13 +13,13 @@ - - We first look for the gui library. This can be set by the - REDHAT_GUI_LIBRARY environment variable. Otherwise, it is named -- gui, and is found in $prefix/share/redhat, where $prefix is -+ gui, and is found in $prefix/share/insight, where $prefix is - determined by looking at the directory where the running executable - is installed. - - We then look for the ide library. This can be set by the - REDHAT_IDE_LIBRARY environment variable. Otherwise, it is named -- ide, and is also found in $prefix/share/redhat. -+ ide, and is also found in $prefix/share/insight. - - It is OK if only one of these libraries exist. If neither exists, - we report an error. -@@ -36,7 +36,7 @@ - bitmapdir -- see below - - Paths(appdir) is set based on the ide_initialize_paths APPNAME -- parameter. If a directory $prefix/share/redhat/APPNAME exists, we -+ parameter. If a directory $prefix/share/insight/APPNAME exists, we - set Paths(appdir) to it. More precisely, we set Paths(appdir) if - an APPNAME directory exists which is a sibling directory of the gui - or ide directory. For convenience of some tools, we also check for -@@ -69,13 +69,13 @@ - # Handle build with --exec-prefix and build without.\n\ - set d [file join [file dirname [pwd]] usr share]\n\ - lappend prefdirs $d\n\ -- lappend guidirs [file join $d redhat gui]\n\ -+ lappend guidirs [file join $d insight gui]\n\ - set d [file join [file dirname [pwd]] share]\n\ - lappend prefdirs $d\n\ -- lappend guidirs [file join $d redhat gui]\n\ -+ lappend guidirs [file join $d insight gui]\n\ - set d [file join [file dirname [file dirname [pwd]]] share]\n\ - lappend prefdirs $d\n\ -- lappend guidirs [file join $d redhat gui]\n\ -+ lappend guidirs [file join $d insight gui]\n\ - set Paths(bindir) [pwd]\n\ - # Base `prefix' on where the `share' dir is found\n\ - foreach sd $prefdirs {\n\ -@@ -110,7 +110,7 @@ - lappend idedirs $env(REDHAT_IDE_LIBRARY)\n\ - }\n\ - foreach d $prefdirs {\n\ -- lappend idedirs [file join $d redhat ide]\n\ -+ lappend idedirs [file join $d insight ide]\n\ - }\n\ - # Try to handle running from the build tree:\n\ - lappend idedirs [file join [file dirname [file dirname $::tcl_library]] libide library]\n\ -@@ -180,9 +180,9 @@ - set here [pwd]\n\ - cd [file dirname [info nameofexecutable]]\n\ - set d [file join [file dirname [pwd]] share]\n\ -- lappend guidirs [file join $d redhat gui]\n\ -+ lappend guidirs [file join $d insight gui]\n\ - set d [file join [file dirname [file dirname [pwd]]] share]\n\ -- lappend guidirs [file join $d redhat gui]\n\ -+ lappend guidirs [file join $d insight gui]\n\ - lappend guidirs [file join [file dirname [file dirname $tcl_library]] libgui library]\n\ - foreach sd $guidirs {\n\ - if {[file exists [file join $sd tclIndex]]} {\n\ diff --git a/insight-gdb-6.6-buildid-locate-rpm.patch b/insight-gdb-6.6-buildid-locate-rpm.patch deleted file mode 100644 index 1e02152..0000000 --- a/insight-gdb-6.6-buildid-locate-rpm.patch +++ /dev/null @@ -1,1486 +0,0 @@ -diff -Naurp insight-10.0.50.20200110.orig/gdb/aclocal.m4 insight-10.0.50.20200110.new/gdb/aclocal.m4 ---- insight-10.0.50.20200110.orig/gdb/aclocal.m4 2020-02-07 00:46:06.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/aclocal.m4 2020-02-07 02:59:48.631861468 +0100 -@@ -11,7 +11,223 @@ - # even the implied warranty of MERCHANTABILITY or FITNESS FOR A - # PARTICULAR PURPOSE. - -+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -+# serial 1 (pkg-config-0.24) -+# -+# Copyright © 2004 Scott James Remnant . -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, but -+# WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+# -+# As a special exception to the GNU General Public License, if you -+# distribute this file as part of a program that contains a -+# configuration script generated by Autoconf, you may include it under -+# the same distribution terms that you use for the rest of that program. -+ -+# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -+# ---------------------------------- -+AC_DEFUN([PKG_PROG_PKG_CONFIG], -+[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) -+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) -+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) -+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) -+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) -+ -+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then -+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) -+fi -+if test -n "$PKG_CONFIG"; then -+ _pkg_min_version=m4_default([$1], [0.9.0]) -+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) -+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then -+ AC_MSG_RESULT([yes]) -+ else -+ AC_MSG_RESULT([no]) -+ PKG_CONFIG="" -+ fi -+fi[]dnl -+])# PKG_PROG_PKG_CONFIG -+ -+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -+# -+# Check to see whether a particular set of modules exists. Similar -+# to PKG_CHECK_MODULES(), but does not set variables or print errors. -+# -+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -+# only at the first occurence in configure.ac, so if the first place -+# it's called might be skipped (such as if it is within an "if", you -+# have to call PKG_CHECK_EXISTS manually -+# -------------------------------------------------------------- -+AC_DEFUN([PKG_CHECK_EXISTS], -+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -+if test -n "$PKG_CONFIG" && \ -+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then -+ m4_default([$2], [:]) -+m4_ifvaln([$3], [else -+ $3])dnl -+fi]) -+ -+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -+# --------------------------------------------- -+m4_define([_PKG_CONFIG], -+[if test -n "$$1"; then -+ pkg_cv_[]$1="$$1" -+ elif test -n "$PKG_CONFIG"; then -+ PKG_CHECK_EXISTS([$3], -+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` -+ test "x$?" != "x0" && pkg_failed=yes ], -+ [pkg_failed=yes]) -+ else -+ pkg_failed=untried -+fi[]dnl -+])# _PKG_CONFIG -+ -+# _PKG_SHORT_ERRORS_SUPPORTED -+# ----------------------------- -+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], -+[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -+ _pkg_short_errors_supported=yes -+else -+ _pkg_short_errors_supported=no -+fi[]dnl -+])# _PKG_SHORT_ERRORS_SUPPORTED -+ -+ -+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -+# [ACTION-IF-NOT-FOUND]) -+# -+# -+# Note that if there is a possibility the first call to -+# PKG_CHECK_MODULES might not happen, you should be sure to include an -+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -+# -+# -+# -------------------------------------------------------------- -+AC_DEFUN([PKG_CHECK_MODULES], -+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl -+ -+pkg_failed=no -+AC_MSG_CHECKING([for $1]) -+ -+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -+_PKG_CONFIG([$1][_LIBS], [libs], [$2]) -+ -+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS -+and $1[]_LIBS to avoid the need to call pkg-config. -+See the pkg-config man page for more details.]) -+ -+if test $pkg_failed = yes; then -+ AC_MSG_RESULT([no]) -+ _PKG_SHORT_ERRORS_SUPPORTED -+ if test $_pkg_short_errors_supported = yes; then -+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` -+ else -+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` -+ fi -+ # Put the nasty error message in config.log where it belongs -+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD -+ -+ m4_default([$4], [AC_MSG_ERROR( -+[Package requirements ($2) were not met: -+ -+$$1_PKG_ERRORS -+ -+Consider adjusting the PKG_CONFIG_PATH environment variable if you -+installed software in a non-standard prefix. -+ -+_PKG_TEXT])[]dnl -+ ]) -+elif test $pkg_failed = untried; then -+ AC_MSG_RESULT([no]) -+ m4_default([$4], [AC_MSG_FAILURE( -+[The pkg-config script could not be found or is too old. Make sure it -+is in your PATH or set the PKG_CONFIG environment variable to the full -+path to pkg-config. -+ -+_PKG_TEXT -+ -+To get pkg-config, see .])[]dnl -+ ]) -+else -+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS -+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS -+ AC_MSG_RESULT([yes]) -+ $3 -+fi[]dnl -+])# PKG_CHECK_MODULES -+ -+ -+# PKG_INSTALLDIR(DIRECTORY) -+# ------------------------- -+# Substitutes the variable pkgconfigdir as the location where a module -+# should install pkg-config .pc files. By default the directory is -+# $libdir/pkgconfig, but the default can be changed by passing -+# DIRECTORY. The user can override through the --with-pkgconfigdir -+# parameter. -+AC_DEFUN([PKG_INSTALLDIR], -+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) -+m4_pushdef([pkg_description], -+ [pkg-config installation directory @<:@]pkg_default[@:>@]) -+AC_ARG_WITH([pkgconfigdir], -+ [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, -+ [with_pkgconfigdir=]pkg_default) -+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) -+m4_popdef([pkg_default]) -+m4_popdef([pkg_description]) -+]) dnl PKG_INSTALLDIR -+ -+ -+# PKG_NOARCH_INSTALLDIR(DIRECTORY) -+# ------------------------- -+# Substitutes the variable noarch_pkgconfigdir as the location where a -+# module should install arch-independent pkg-config .pc files. By -+# default the directory is $datadir/pkgconfig, but the default can be -+# changed by passing DIRECTORY. The user can override through the -+# --with-noarch-pkgconfigdir parameter. -+AC_DEFUN([PKG_NOARCH_INSTALLDIR], -+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) -+m4_pushdef([pkg_description], -+ [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) -+AC_ARG_WITH([noarch-pkgconfigdir], -+ [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, -+ [with_noarch_pkgconfigdir=]pkg_default) -+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) -+m4_popdef([pkg_default]) -+m4_popdef([pkg_description]) -+]) dnl PKG_NOARCH_INSTALLDIR -+ -+ -+# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, -+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -+# ------------------------------------------- -+# Retrieves the value of the pkg-config variable for the given module. -+AC_DEFUN([PKG_CHECK_VAR], -+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl -+ -+_PKG_CONFIG([$1], [variable="][$3]["], [$2]) -+AS_VAR_COPY([$1], [pkg_cv_][$1]) -+ -+AS_VAR_IF([$1], [""], [$5], [$4])dnl -+])# PKG_CHECK_VAR -+ - m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) -+ - # AM_AUX_DIR_EXPAND -*- Autoconf -*- - - # Copyright (C) 2001-2018 Free Software Foundation, Inc. -diff -Naurp insight-10.0.50.20200110.orig/gdb/build-id.c insight-10.0.50.20200110.new/gdb/build-id.c ---- insight-10.0.50.20200110.orig/gdb/build-id.c 2020-02-07 02:59:04.301420242 +0100 -+++ insight-10.0.50.20200110.new/gdb/build-id.c 2020-02-07 02:59:48.632861478 +0100 -@@ -33,6 +33,7 @@ - #include "gdb_bfd.h" - #include "gdbcmd.h" - #include "gdbcore.h" -+#include "inferior.h" - #include "libbfd.h" - #include "objfiles.h" - #include "observable.h" -@@ -698,8 +699,359 @@ build_id_to_filename (const struct bfd_b - return result; - } - -+#ifdef HAVE_LIBRPM -+ -+#include -+#include -+#include -+#include -+#ifdef DLOPEN_LIBRPM -+#include -+#endif -+ -+/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files -+ and avoid their duplicities during a single inferior run. */ -+ -+static struct htab *missing_rpm_hash; -+ -+/* This MISSING_RPM_LIST tracker is used to collect and print as a single line -+ all the rpms right before the nearest GDB prompt. It gets cleared after -+ each such print (it is questionable if we should clear it after the print). -+ */ -+ -+struct missing_rpm -+ { -+ struct missing_rpm *next; -+ char rpm[1]; -+ }; -+static struct missing_rpm *missing_rpm_list; -+static int missing_rpm_list_entries; -+ -+/* Returns the count of newly added rpms. */ -+ -+static int -+missing_rpm_enlist (const char *filename) -+{ -+ static int rpm_init_done = 0; -+ rpmts ts; -+ rpmdbMatchIterator mi; -+ int count = 0; -+ -+#ifdef DLOPEN_LIBRPM -+ /* Duplicate here the declarations to verify they match. The same sanity -+ check is present also in `configure.ac'. */ -+ extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); -+ static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg); -+ extern int rpmReadConfigFiles(const char * file, const char * target); -+ static int (*rpmReadConfigFiles_p) (const char * file, const char * target); -+ extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); -+ static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi); -+ extern Header rpmdbNextIterator(rpmdbMatchIterator mi); -+ static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi); -+ extern rpmts rpmtsCreate(void); -+ static rpmts (*rpmtsCreate_p) (void); -+ extern rpmts rpmtsFree(rpmts ts); -+ static rpmts (*rpmtsFree_p) (rpmts ts); -+ extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, -+ const void * keyp, size_t keylen); -+ static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts, -+ rpmTag rpmtag, -+ const void *keyp, -+ size_t keylen); -+#else /* !DLOPEN_LIBRPM */ -+# define headerFormat_p headerFormat -+# define rpmReadConfigFiles_p rpmReadConfigFiles -+# define rpmdbFreeIterator_p rpmdbFreeIterator -+# define rpmdbNextIterator_p rpmdbNextIterator -+# define rpmtsCreate_p rpmtsCreate -+# define rpmtsFree_p rpmtsFree -+# define rpmtsInitIterator_p rpmtsInitIterator -+#endif /* !DLOPEN_LIBRPM */ -+ -+ gdb_assert (filename != NULL); -+ -+ if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0) -+ return 0; -+ -+ if (is_target_filename (filename)) -+ return 0; -+ -+ if (filename[0] != '/') -+ { -+ warning (_("Ignoring non-absolute filename: <%s>"), filename); -+ return 0; -+ } -+ -+ if (!rpm_init_done) -+ { -+ static int init_tried; -+ -+ /* Already failed the initialization before? */ -+ if (init_tried) -+ return 0; -+ init_tried = 1; -+ -+#ifdef DLOPEN_LIBRPM -+ { -+ void *h; -+ -+ h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY); -+ if (!h) -+ { -+ warning (_("Unable to open \"%s\" (%s), " -+ "missing debuginfos notifications will not be displayed"), -+ DLOPEN_LIBRPM, dlerror ()); -+ return 0; -+ } -+ -+ if (!((headerFormat_p = (char *(*) (Header h, const char * fmt, errmsg_t *errmsg)) dlsym (h, "headerFormat")) -+ && (rpmReadConfigFiles_p = (int (*) (const char * file, const char * target)) dlsym (h, "rpmReadConfigFiles")) -+ && (rpmdbFreeIterator_p = (rpmdbMatchIterator (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbFreeIterator")) -+ && (rpmdbNextIterator_p = (Header (*) (rpmdbMatchIterator mi)) dlsym (h, "rpmdbNextIterator")) -+ && (rpmtsCreate_p = (rpmts (*) (void)) dlsym (h, "rpmtsCreate")) -+ && (rpmtsFree_p = (rpmts (*) (rpmts ts)) dlsym (h, "rpmtsFree")) -+ && (rpmtsInitIterator_p = (rpmdbMatchIterator (*) (const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)) dlsym (h, "rpmtsInitIterator")))) -+ { -+ warning (_("Opened library \"%s\" is incompatible (%s), " -+ "missing debuginfos notifications will not be displayed"), -+ DLOPEN_LIBRPM, dlerror ()); -+ if (dlclose (h)) -+ warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM, -+ dlerror ()); -+ return 0; -+ } -+ } -+#endif /* DLOPEN_LIBRPM */ -+ -+ if (rpmReadConfigFiles_p (NULL, NULL) != 0) -+ { -+ warning (_("Error reading the rpm configuration files")); -+ return 0; -+ } -+ -+ rpm_init_done = 1; -+ } -+ -+ ts = rpmtsCreate_p (); -+ -+ mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0); -+ if (mi != NULL) -+ { -+ for (;;) -+ { -+ Header h; -+ char *debuginfo, **slot, *s, *s2; -+ errmsg_t err; -+ size_t srcrpmlen = sizeof (".src.rpm") - 1; -+ size_t debuginfolen = sizeof ("-debuginfo") - 1; -+ rpmdbMatchIterator mi_debuginfo; -+ -+ h = rpmdbNextIterator_p (mi); -+ if (h == NULL) -+ break; -+ -+ /* Verify the debuginfo file is not already installed. */ -+ -+ debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}", -+ &err); -+ if (!debuginfo) -+ { -+ warning (_("Error querying the rpm file `%s': %s"), filename, -+ err); -+ continue; -+ } -+ /* s = `.src.rpm-debuginfo.%{arch}' */ -+ s = strrchr (debuginfo, '-') - srcrpmlen; -+ s2 = NULL; -+ if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0) -+ { -+ /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */ -+ s2 = (char *) memrchr (debuginfo, '-', s - debuginfo); -+ } -+ if (s2) -+ { -+ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */ -+ s2 = (char *) memrchr (debuginfo, '-', s2 - debuginfo); -+ } -+ if (!s2) -+ { -+ warning (_("Error querying the rpm file `%s': %s"), filename, -+ debuginfo); -+ xfree (debuginfo); -+ continue; -+ } -+ /* s = `.src.rpm-debuginfo.%{arch}' */ -+ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */ -+ memmove (s2 + debuginfolen, s2, s - s2); -+ memcpy (s2, "-debuginfo", debuginfolen); -+ /* s = `XXXX.%{arch}' */ -+ /* strlen ("XXXX") == srcrpmlen + debuginfolen */ -+ /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */ -+ /* strlen ("XX") == srcrpmlen */ -+ memmove (s + debuginfolen, s + srcrpmlen + debuginfolen, -+ strlen (s + srcrpmlen + debuginfolen) + 1); -+ /* s = `-debuginfo-%{version}-%{release}.%{arch}' */ -+ -+ /* RPMDBI_PACKAGES requires keylen == sizeof (int). */ -+ /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */ -+ mi_debuginfo = rpmtsInitIterator_p (ts, (rpmTag) RPMDBI_LABEL, debuginfo, 0); -+ xfree (debuginfo); -+ if (mi_debuginfo) -+ { -+ rpmdbFreeIterator_p (mi_debuginfo); -+ count = 0; -+ break; -+ } -+ -+ /* The allocated memory gets utilized below for MISSING_RPM_HASH. */ -+ debuginfo = headerFormat_p (h, -+ "%{name}-%{version}-%{release}.%{arch}", -+ &err); -+ if (!debuginfo) -+ { -+ warning (_("Error querying the rpm file `%s': %s"), filename, -+ err); -+ continue; -+ } -+ -+ /* Base package name for `debuginfo-install'. We do not use the -+ `yum' command directly as the line -+ yum --enablerepo='*debug*' install NAME-debuginfo.ARCH -+ would be more complicated than just: -+ debuginfo-install NAME-VERSION-RELEASE.ARCH -+ Do not supply the rpm base name (derived from .src.rpm name) as -+ debuginfo-install is unable to install the debuginfo package if -+ the base name PKG binary rpm is not installed while for example -+ PKG-libs would be installed (RH Bug 467901). -+ FUTURE: After multiple debuginfo versions simultaneously installed -+ get supported the support for the VERSION-RELEASE tags handling -+ may need an update. */ -+ -+ if (missing_rpm_hash == NULL) -+ { -+ /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE -+ should not deallocate the entries. */ -+ -+ missing_rpm_hash = htab_create_alloc (64, htab_hash_string, -+ (int (*) (const void *, const void *)) streq, -+ NULL, xcalloc, xfree); -+ } -+ slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT); -+ /* XCALLOC never returns NULL. */ -+ gdb_assert (slot != NULL); -+ if (*slot == NULL) -+ { -+ struct missing_rpm *missing_rpm; -+ -+ *slot = debuginfo; -+ -+ missing_rpm = (struct missing_rpm *) xmalloc (sizeof (*missing_rpm) + strlen (debuginfo)); -+ strcpy (missing_rpm->rpm, debuginfo); -+ missing_rpm->next = missing_rpm_list; -+ missing_rpm_list = missing_rpm; -+ missing_rpm_list_entries++; -+ } -+ else -+ xfree (debuginfo); -+ count++; -+ } -+ -+ rpmdbFreeIterator_p (mi); -+ } -+ -+ rpmtsFree_p (ts); -+ -+ return count; -+} -+ -+static bool -+missing_rpm_list_compar (const char *ap, const char *bp) -+{ -+ return strcoll (ap, bp) < 0; -+} -+ -+/* It returns a NULL-terminated array of strings needing to be FREEd. It may -+ also return only NULL. */ -+ -+static void -+missing_rpm_list_print (void) -+{ -+ struct missing_rpm *list_iter; -+ -+ if (missing_rpm_list_entries == 0) -+ return; -+ -+ std::vector array (missing_rpm_list_entries); -+ size_t idx = 0; -+ -+ for (list_iter = missing_rpm_list; list_iter != NULL; -+ list_iter = list_iter->next) -+ { -+ array[idx++] = list_iter->rpm; -+ } -+ gdb_assert (idx == missing_rpm_list_entries); -+ -+ std::sort (array.begin (), array.end (), missing_rpm_list_compar); -+ -+ printf_unfiltered (_("Missing separate debuginfos, use: %s"), -+#ifdef DNF_DEBUGINFO_INSTALL -+ "dnf " -+#endif -+ "debuginfo-install"); -+ for (const char *el : array) -+ { -+ putchar_unfiltered (' '); -+ puts_unfiltered (el); -+ } -+ putchar_unfiltered ('\n'); -+ -+ while (missing_rpm_list != NULL) -+ { -+ list_iter = missing_rpm_list; -+ missing_rpm_list = list_iter->next; -+ xfree (list_iter); -+ } -+ missing_rpm_list_entries = 0; -+} -+ -+static void -+missing_rpm_change (void) -+{ -+ debug_flush_missing (); -+ -+ gdb_assert (missing_rpm_list == NULL); -+ if (missing_rpm_hash != NULL) -+ { -+ htab_delete (missing_rpm_hash); -+ missing_rpm_hash = NULL; -+ } -+} -+ -+enum missing_exec -+ { -+ /* Init state. EXEC_BFD also still could be NULL. */ -+ MISSING_EXEC_NOT_TRIED, -+ /* We saw a non-NULL EXEC_BFD but RPM has no info about it. */ -+ MISSING_EXEC_NOT_FOUND, -+ /* We found EXEC_BFD by RPM and we either have its symbols (either embedded -+ or separate) or the main executable's RPM is now contained in -+ MISSING_RPM_HASH. */ -+ MISSING_EXEC_ENLISTED -+ }; -+static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED; -+ -+#endif /* HAVE_LIBRPM */ -+ -+void -+debug_flush_missing (void) -+{ -+#ifdef HAVE_LIBRPM -+ missing_rpm_list_print (); -+#endif -+} -+ - /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages -- Try to install the hash file ... -+ yum --enablerepo='*debug*' install ... - avoidance. */ - - struct missing_filepair -@@ -753,11 +1105,17 @@ missing_filepair_change (void) - /* All their memory came just from missing_filepair_OBSTACK. */ - missing_filepair_hash = NULL; - } -+#ifdef HAVE_LIBRPM -+ missing_exec = MISSING_EXEC_NOT_TRIED; -+#endif - } - - static void - debug_print_executable_changed (void) - { -+#ifdef HAVE_LIBRPM -+ missing_rpm_change (); -+#endif - missing_filepair_change (); - } - -@@ -824,14 +1182,38 @@ debug_print_missing (const char *binary, - - *slot = missing_filepair; - -- /* We do not collect and flush these messages as each such message -- already requires its own separate lines. */ -+#ifdef HAVE_LIBRPM -+ if (missing_exec == MISSING_EXEC_NOT_TRIED) -+ { -+ const char *execfilename = get_exec_file (0); - -- fprintf_unfiltered (gdb_stdlog, -- _("Missing separate debuginfo for %s\n"), binary); -- if (debug != NULL) -- fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"), -- debug); -+ if (execfilename != NULL) -+ { -+ if (missing_rpm_enlist (execfilename) == 0) -+ missing_exec = MISSING_EXEC_NOT_FOUND; -+ else -+ missing_exec = MISSING_EXEC_ENLISTED; -+ } -+ } -+ if (missing_exec != MISSING_EXEC_ENLISTED) -+ if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0) -+ && (debug == NULL || missing_rpm_enlist (debug) == 0)) -+#endif /* HAVE_LIBRPM */ -+ { -+ /* We do not collect and flush these messages as each such message -+ already requires its own separate lines. */ -+ -+ fprintf_unfiltered (gdb_stdlog, -+ _("Missing separate debuginfo for %s\n"), binary); -+ if (debug != NULL) -+ fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"), -+#ifdef DNF_DEBUGINFO_INSTALL -+ "dnf" -+#else -+ "yum" -+#endif -+ " --enablerepo='*debug*' install", debug); -+ } - } - - /* See build-id.h. */ -diff -Naurp insight-10.0.50.20200110.orig/gdb/config.in insight-10.0.50.20200110.new/gdb/config.in ---- insight-10.0.50.20200110.orig/gdb/config.in 2019-12-13 10:42:59.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/config.in 2020-02-07 02:59:48.632861478 +0100 -@@ -36,6 +36,9 @@ - /* Define to BFD's default target vector. */ - #undef DEFAULT_BFD_VEC - -+/* librpm version specific library name to dlopen. */ -+#undef DLOPEN_LIBRPM -+ - /* Define to 1 if translation of program messages to the user's native - language is requested. */ - #undef ENABLE_NLS -@@ -245,6 +248,9 @@ - /* Define if you have the mpfr library. */ - #undef HAVE_LIBMPFR - -+/* Define if librpm library is being used. */ -+#undef HAVE_LIBRPM -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_LIBUNWIND_IA64_H - -diff -Naurp insight-10.0.50.20200110.orig/gdb/configure insight-10.0.50.20200110.new/gdb/configure ---- insight-10.0.50.20200110.orig/gdb/configure 2020-02-07 00:46:07.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/configure 2020-02-07 02:59:48.637861528 +0100 -@@ -763,6 +763,11 @@ CODESIGN_CERT - HAVE_NATIVE_GCORE_TARGET - TARGET_OBS - subdirs -+RPM_LIBS -+RPM_CFLAGS -+PKG_CONFIG_LIBDIR -+PKG_CONFIG_PATH -+PKG_CONFIG - GDB_DATADIR - DEBUGDIR - MAKEINFO_EXTRA_FLAGS -@@ -866,6 +871,7 @@ with_gdb_datadir - with_relocated_sources - with_auto_load_dir - with_auto_load_safe_path -+with_rpm - enable_targets - enable_64_bit_bfd - enable_gdbmi -@@ -928,6 +934,11 @@ CCC - CPP - MAKEINFO - MAKEINFOFLAGS -+PKG_CONFIG -+PKG_CONFIG_PATH -+PKG_CONFIG_LIBDIR -+RPM_CFLAGS -+RPM_LIBS - YACC - YFLAGS - XMKMF' -@@ -1600,6 +1611,8 @@ Optional Packages: - [--with-auto-load-dir] - --without-auto-load-safe-path - do not restrict auto-loaded files locations -+ --with-rpm query rpm database for missing debuginfos (yes/no, -+ def. auto=librpm.so) - --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets - --with-curses use the curses library instead of the termcap - library -@@ -1663,6 +1676,13 @@ Some influential environment variables: - MAKEINFO Parent configure detects if it is of sufficient version. - MAKEINFOFLAGS - Parameters for MAKEINFO. -+ PKG_CONFIG path to pkg-config utility -+ PKG_CONFIG_PATH -+ directories to add to pkg-config's search path -+ PKG_CONFIG_LIBDIR -+ path overriding pkg-config's built-in search path -+ RPM_CFLAGS C compiler flags for RPM, overriding pkg-config -+ RPM_LIBS linker flags for RPM, overriding pkg-config - YACC The `Yet Another Compiler Compiler' implementation to use. - Defaults to the first program found out of: `bison -y', `byacc', - `yacc'. -@@ -6589,6 +6609,494 @@ _ACEOF - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5 - $as_echo "$with_auto_load_safe_path" >&6; } - -+# Integration with rpm library to support missing debuginfo suggestions. -+# --without-rpm: Disable any rpm support. -+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime. -+# Even with runtime missing `libname.so' GDB will still other run correctly. -+# Missing `libname.so' during ./configure will abort the configuration. -+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific -+# minor version first such as `librpm-4.6.so' as minor version differences -+# mean API+ABI incompatibility. If the specific match versioned library name -+# could not be found still open dynamically at least `librpm.so'. -+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try -+# to find librpm for compilation-time linking by pkg-config. GDB binary will -+# be probably linked with the version specific library (as `librpm-4.6.so'). -+# Failure to find librpm by pkg-config will abort the configuration. -+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config -+# cannot find librpm use to the rpmless compilation (like `--without-rpm'). -+ -+ -+# Check whether --with-rpm was given. -+if test "${with_rpm+set}" = set; then : -+ withval=$with_rpm; -+else -+ with_rpm="auto" -+fi -+ -+ -+ -+ -+if test "x$with_rpm" != "xno"; then -+ if test "x$with_rpm" = "xyes"; then -+ LIBRPM="librpm.so" -+ RPM_REQUIRE=true -+ DLOPEN_REQUIRE=false -+ elif test "x$with_rpm" = "xauto"; then -+ LIBRPM="librpm.so" -+ RPM_REQUIRE=false -+ DLOPEN_REQUIRE=false -+ else -+ LIBRPM="$with_rpm" -+ RPM_REQUIRE=true -+ DLOPEN_REQUIRE=true -+ fi -+ LIBRPM_STRING='"'"$LIBRPM"'"' -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5 -+$as_echo_n "checking specific librpm version... " >&6; } -+ HAVE_DLOPEN_LIBRPM=false -+ save_LIBS="$LIBS" -+ LIBS="$LIBS -ldl" -+ if test "$cross_compiling" = yes; then : -+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -+as_fn_error "cannot run test program while cross compiling -+See \`config.log' for more details." "$LINENO" 5; } -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+#include -+#include -+#include -+ -+int -+main () -+{ -+ -+ void *h; -+ const char *const *rpmverp; -+ FILE *f; -+ -+ f = fopen ("conftest.out", "w"); -+ if (!f) -+ { -+ fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out", -+ strerror (errno)); -+ return 1; -+ } -+ h = dlopen ($LIBRPM_STRING, RTLD_LAZY); -+ if (!h) -+ { -+ fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ()); -+ return 1; -+ } -+ rpmverp = dlsym (h, "RPMVERSION"); -+ if (!rpmverp) -+ { -+ fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ()); -+ return 1; -+ } -+ fprintf (stderr, "RPMVERSION is: \""); -+ fprintf (stderr, "%s\"\n", *rpmverp); -+ -+ /* Try to find the specific librpm version only for "librpm.so" as we do -+ not know how to assemble the version string otherwise. */ -+ -+ if (strcmp ("librpm.so", $LIBRPM_STRING) != 0) -+ { -+ fprintf (f, "%s\n", $LIBRPM_STRING); -+ return 0; -+ } -+ else -+ { -+ char *h2_name; -+ void *h2; -+ int major, minor; -+ -+ if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2) -+ { -+ fprintf (stderr, "Unable to parse RPMVERSION.\n"); -+ fprintf (f, "%s\n", $LIBRPM_STRING); -+ return 0; -+ } -+ /* Avoid the square brackets by malloc. */ -+ h2_name = malloc (64); -+ sprintf (h2_name, "librpm-%d.%d.so", major, minor); -+ h2 = dlopen (h2_name, RTLD_LAZY); -+ if (!h2) -+ { -+ fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ()); -+ fprintf (f, "%s\n", $LIBRPM_STRING); -+ return 0; -+ } -+ if (h2 != h) -+ { -+ fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n", -+ $LIBRPM_STRING, h2_name); -+ fprintf (f, "%s\n", $LIBRPM_STRING); -+ return 0; -+ } -+ /* Found the valid .so name with a specific version. */ -+ fprintf (f, "%s\n", h2_name); -+ return 0; -+ } -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_run "$LINENO"; then : -+ -+ DLOPEN_LIBRPM="`cat conftest.out`" -+ if test "x$DLOPEN_LIBRPM" != "x"; then -+ HAVE_DLOPEN_LIBRPM=true -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5 -+$as_echo "$DLOPEN_LIBRPM" >&6; } -+ fi -+ -+fi -+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ -+ conftest.$ac_objext conftest.beam conftest.$ac_ext -+fi -+ -+ rm -f conftest.out -+ -+ -+ -+ if $HAVE_DLOPEN_LIBRPM; then -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5 -+$as_echo_n "checking rpm library API compatibility... " >&6; } -+ # The compilation requires -Werror to verify anything. -+ save_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS -Werror" -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Duplicate here the declarations to verify they match "elfread.c". */ -+#include -+#include -+#include -+#include -+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); -+extern int rpmReadConfigFiles(const char * file, const char * target); -+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); -+extern Header rpmdbNextIterator(rpmdbMatchIterator mi); -+extern rpmts rpmtsCreate(void); -+extern rpmts rpmtsFree(rpmts ts); -+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, -+ const void * keyp, size_t keylen); -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ -+ LIBRPM_COMPAT=true -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -+$as_echo "yes" >&6; } -+ -+else -+ -+ LIBRPM_COMPAT=false -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ CFLAGS="$save_CFLAGS" -+ -+ if ! $LIBRPM_COMPAT; then -+ HAVE_DLOPEN_LIBRPM=false -+ fi -+ fi -+ -+ if $HAVE_DLOPEN_LIBRPM; then -+ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"' -+ -+cat >>confdefs.h <<_ACEOF -+#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING -+_ACEOF -+ -+ -+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h -+ -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ LIBS="$save_LIBS" -+ if $DLOPEN_REQUIRE; then -+ as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5 -+ fi -+ -+ -+ -+ -+ -+ -+ -+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then -+ if test -n "$ac_tool_prefix"; then -+ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ case $PKG_CONFIG in -+ [\\/]* | ?:[\\/]*) -+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. -+ ;; -+ *) -+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+ ;; -+esac -+fi -+PKG_CONFIG=$ac_cv_path_PKG_CONFIG -+if test -n "$PKG_CONFIG"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -+$as_echo "$PKG_CONFIG" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ -+fi -+if test -z "$ac_cv_path_PKG_CONFIG"; then -+ ac_pt_PKG_CONFIG=$PKG_CONFIG -+ # Extract the first word of "pkg-config", so it can be a program name with args. -+set dummy pkg-config; ac_word=$2 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -+$as_echo_n "checking for $ac_word... " >&6; } -+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ case $ac_pt_PKG_CONFIG in -+ [\\/]* | ?:[\\/]*) -+ ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. -+ ;; -+ *) -+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -+for as_dir in $PATH -+do -+ IFS=$as_save_IFS -+ test -z "$as_dir" && as_dir=. -+ for ac_exec_ext in '' $ac_executable_extensions; do -+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then -+ ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" -+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 -+ break 2 -+ fi -+done -+ done -+IFS=$as_save_IFS -+ -+ ;; -+esac -+fi -+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -+if test -n "$ac_pt_PKG_CONFIG"; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -+$as_echo "$ac_pt_PKG_CONFIG" >&6; } -+else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+fi -+ -+ if test "x$ac_pt_PKG_CONFIG" = x; then -+ PKG_CONFIG="" -+ else -+ case $cross_compiling:$ac_tool_warned in -+yes:) -+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -+ac_tool_warned=yes ;; -+esac -+ PKG_CONFIG=$ac_pt_PKG_CONFIG -+ fi -+else -+ PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -+fi -+ -+fi -+if test -n "$PKG_CONFIG"; then -+ _pkg_min_version=0.9.0 -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } -+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -+$as_echo "yes" >&6; } -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ PKG_CONFIG="" -+ fi -+fi -+ -+pkg_failed=no -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5 -+$as_echo_n "checking for RPM... " >&6; } -+ -+if test -n "$RPM_CFLAGS"; then -+ pkg_cv_RPM_CFLAGS="$RPM_CFLAGS" -+ elif test -n "$PKG_CONFIG"; then -+ if test -n "$PKG_CONFIG" && \ -+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5 -+ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5 -+ ac_status=$? -+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -+ test $ac_status = 0; }; then -+ pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null` -+ test "x$?" != "x0" && pkg_failed=yes -+else -+ pkg_failed=yes -+fi -+ else -+ pkg_failed=untried -+fi -+if test -n "$RPM_LIBS"; then -+ pkg_cv_RPM_LIBS="$RPM_LIBS" -+ elif test -n "$PKG_CONFIG"; then -+ if test -n "$PKG_CONFIG" && \ -+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5 -+ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5 -+ ac_status=$? -+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 -+ test $ac_status = 0; }; then -+ pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null` -+ test "x$?" != "x0" && pkg_failed=yes -+else -+ pkg_failed=yes -+fi -+ else -+ pkg_failed=untried -+fi -+ -+ -+ -+if test $pkg_failed = yes; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ -+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -+ _pkg_short_errors_supported=yes -+else -+ _pkg_short_errors_supported=no -+fi -+ if test $_pkg_short_errors_supported = yes; then -+ RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "rpm" 2>&1` -+ else -+ RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "rpm" 2>&1` -+ fi -+ # Put the nasty error message in config.log where it belongs -+ echo "$RPM_PKG_ERRORS" >&5 -+ -+ HAVE_LIBRPM=false -+elif test $pkg_failed = untried; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ HAVE_LIBRPM=false -+else -+ RPM_CFLAGS=$pkg_cv_RPM_CFLAGS -+ RPM_LIBS=$pkg_cv_RPM_LIBS -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -+$as_echo "yes" >&6; } -+ HAVE_LIBRPM=true -+fi -+ -+ if $HAVE_LIBRPM; then -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5 -+$as_echo_n "checking rpm library API compatibility... " >&6; } -+ # The compilation requires -Werror to verify anything. -+ save_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS -Werror" -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Duplicate here the declarations to verify they match "elfread.c". */ -+#include -+#include -+#include -+#include -+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); -+extern int rpmReadConfigFiles(const char * file, const char * target); -+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); -+extern Header rpmdbNextIterator(rpmdbMatchIterator mi); -+extern rpmts rpmtsCreate(void); -+extern rpmts rpmtsFree(rpmts ts); -+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, -+ const void * keyp, size_t keylen); -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_compile "$LINENO"; then : -+ -+ LIBRPM_COMPAT=true -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -+$as_echo "yes" >&6; } -+ -+else -+ -+ LIBRPM_COMPAT=false -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -+$as_echo "no" >&6; } -+ -+fi -+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -+ CFLAGS="$save_CFLAGS" -+ -+ if ! $LIBRPM_COMPAT; then -+ HAVE_LIBRPM=false -+ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB" -+ fi -+ fi -+ -+ if $HAVE_LIBRPM; then -+ -+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h -+ -+ CFLAGS="$CFLAGS $RPM_CFLAGS" -+ LIBS="$LIBS $RPM_LIBS" -+ else -+ if $RPM_REQUIRE; then -+ as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5 -+ else -+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5 -+$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;} -+ fi -+ fi -+ fi -+fi -+ - - - subdirs="$subdirs testsuite" -diff -Naurp insight-10.0.50.20200110.orig/gdb/configure.ac insight-10.0.50.20200110.new/gdb/configure.ac ---- insight-10.0.50.20200110.orig/gdb/configure.ac 2020-02-07 02:59:04.276419993 +0100 -+++ insight-10.0.50.20200110.new/gdb/configure.ac 2020-02-07 02:59:48.638861538 +0100 -@@ -144,6 +144,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escap - [Directories safe to hold auto-loaded files.]) - AC_MSG_RESULT([$with_auto_load_safe_path]) - -+# Integration with rpm library to support missing debuginfo suggestions. -+# --without-rpm: Disable any rpm support. -+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime. -+# Even with runtime missing `libname.so' GDB will still other run correctly. -+# Missing `libname.so' during ./configure will abort the configuration. -+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific -+# minor version first such as `librpm-4.6.so' as minor version differences -+# mean API+ABI incompatibility. If the specific match versioned library name -+# could not be found still open dynamically at least `librpm.so'. -+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try -+# to find librpm for compilation-time linking by pkg-config. GDB binary will -+# be probably linked with the version specific library (as `librpm-4.6.so'). -+# Failure to find librpm by pkg-config will abort the configuration. -+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config -+# cannot find librpm use to the rpmless compilation (like `--without-rpm'). -+ -+AC_ARG_WITH([rpm], -+ [AS_HELP_STRING([--with-rpm], -+ [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"]) -+ -+m4_pattern_allow([^AC_MSG_ERROR$]) -+m4_pattern_allow([^AC_MSG_WARN$]) -+if test "x$with_rpm" != "xno"; then -+ if test "x$with_rpm" = "xyes"; then -+ LIBRPM="librpm.so" -+ RPM_REQUIRE=true -+ DLOPEN_REQUIRE=false -+ elif test "x$with_rpm" = "xauto"; then -+ LIBRPM="librpm.so" -+ RPM_REQUIRE=false -+ DLOPEN_REQUIRE=false -+ else -+ LIBRPM="$with_rpm" -+ RPM_REQUIRE=true -+ DLOPEN_REQUIRE=true -+ fi -+ LIBRPM_STRING='"'"$LIBRPM"'"' -+ -+ AC_MSG_CHECKING([specific librpm version]) -+ HAVE_DLOPEN_LIBRPM=false -+ save_LIBS="$LIBS" -+ LIBS="$LIBS -ldl" -+ AC_RUN_IFELSE(AC_LANG_PROGRAM([[ -+#include -+#include -+#include -+ ]], [[ -+ void *h; -+ const char *const *rpmverp; -+ FILE *f; -+ -+ f = fopen ("conftest.out", "w"); -+ if (!f) -+ { -+ fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out", -+ strerror (errno)); -+ return 1; -+ } -+ h = dlopen ($LIBRPM_STRING, RTLD_LAZY); -+ if (!h) -+ { -+ fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ()); -+ return 1; -+ } -+ rpmverp = dlsym (h, "RPMVERSION"); -+ if (!rpmverp) -+ { -+ fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ()); -+ return 1; -+ } -+ fprintf (stderr, "RPMVERSION is: \""); -+ fprintf (stderr, "%s\"\n", *rpmverp); -+ -+ /* Try to find the specific librpm version only for "librpm.so" as we do -+ not know how to assemble the version string otherwise. */ -+ -+ if (strcmp ("librpm.so", $LIBRPM_STRING) != 0) -+ { -+ fprintf (f, "%s\n", $LIBRPM_STRING); -+ return 0; -+ } -+ else -+ { -+ char *h2_name; -+ void *h2; -+ int major, minor; -+ -+ if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2) -+ { -+ fprintf (stderr, "Unable to parse RPMVERSION.\n"); -+ fprintf (f, "%s\n", $LIBRPM_STRING); -+ return 0; -+ } -+ /* Avoid the square brackets by malloc. */ -+ h2_name = malloc (64); -+ sprintf (h2_name, "librpm-%d.%d.so", major, minor); -+ h2 = dlopen (h2_name, RTLD_LAZY); -+ if (!h2) -+ { -+ fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ()); -+ fprintf (f, "%s\n", $LIBRPM_STRING); -+ return 0; -+ } -+ if (h2 != h) -+ { -+ fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n", -+ $LIBRPM_STRING, h2_name); -+ fprintf (f, "%s\n", $LIBRPM_STRING); -+ return 0; -+ } -+ /* Found the valid .so name with a specific version. */ -+ fprintf (f, "%s\n", h2_name); -+ return 0; -+ } -+ ]]), [ -+ DLOPEN_LIBRPM="`cat conftest.out`" -+ if test "x$DLOPEN_LIBRPM" != "x"; then -+ HAVE_DLOPEN_LIBRPM=true -+ AC_MSG_RESULT($DLOPEN_LIBRPM) -+ fi -+ ]) -+ rm -f conftest.out -+ -+ m4_define([CHECK_LIBRPM_COMPAT], [ -+ AC_MSG_CHECKING([rpm library API compatibility]) -+ # The compilation requires -Werror to verify anything. -+ save_CFLAGS="$CFLAGS" -+ CFLAGS="$CFLAGS -Werror" -+ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ -+/* Duplicate here the declarations to verify they match "elfread.c". */ -+#include -+#include -+#include -+#include -+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg); -+extern int rpmReadConfigFiles(const char * file, const char * target); -+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi); -+extern Header rpmdbNextIterator(rpmdbMatchIterator mi); -+extern rpmts rpmtsCreate(void); -+extern rpmts rpmtsFree(rpmts ts); -+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, -+ const void * keyp, size_t keylen); -+ ]]), [ -+ LIBRPM_COMPAT=true -+ AC_MSG_RESULT(yes) -+ ], [ -+ LIBRPM_COMPAT=false -+ AC_MSG_RESULT(no) -+ ]) -+ CFLAGS="$save_CFLAGS" -+ ]) -+ -+ if $HAVE_DLOPEN_LIBRPM; then -+ CHECK_LIBRPM_COMPAT -+ if ! $LIBRPM_COMPAT; then -+ HAVE_DLOPEN_LIBRPM=false -+ fi -+ fi -+ -+ if $HAVE_DLOPEN_LIBRPM; then -+ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"' -+ AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.]) -+ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.]) -+ else -+ AC_MSG_RESULT(no) -+ LIBS="$save_LIBS" -+ if $DLOPEN_REQUIRE; then -+ AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.]) -+ fi -+ PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false]) -+ -+ if $HAVE_LIBRPM; then -+ CHECK_LIBRPM_COMPAT -+ if ! $LIBRPM_COMPAT; then -+ HAVE_LIBRPM=false -+ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB" -+ fi -+ fi -+ -+ if $HAVE_LIBRPM; then -+ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.]) -+ CFLAGS="$CFLAGS $RPM_CFLAGS" -+ LIBS="$LIBS $RPM_LIBS" -+ else -+ if $RPM_REQUIRE; then -+ AC_MSG_ERROR($RPM_PKG_ERRORS) -+ else -+ AC_MSG_WARN($RPM_PKG_ERRORS) -+ fi -+ fi -+ fi -+fi -+ - AC_CONFIG_SUBDIRS(testsuite) - - # Check whether to support alternative target configurations -diff -Naurp insight-10.0.50.20200110.orig/gdb/event-top.c insight-10.0.50.20200110.new/gdb/event-top.c ---- insight-10.0.50.20200110.orig/gdb/event-top.c 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/event-top.c 2020-02-07 02:59:48.639861548 +0100 -@@ -41,6 +41,7 @@ - #include "ser-event.h" - #include "gdb_select.h" - #include "gdbsupport/gdb-sigmask.h" -+#include "symfile.h" - - /* readline include files. */ - #include "readline/readline.h" -@@ -363,6 +364,8 @@ display_gdb_prompt (const char *new_prom - /* Reset the nesting depth used when trace-commands is set. */ - reset_command_nest_depth (); - -+ debug_flush_missing (); -+ - /* Do not call the python hook on an explicit prompt change as - passed to this function, as this forms a secondary/local prompt, - IE, displayed but not set. */ -@@ -772,7 +775,10 @@ command_line_handler (gdb::unique_xmallo - command_handler (cmd); - - if (ui->prompt_state != PROMPTED) -- display_gdb_prompt (0); -+ { -+ debug_flush_missing (); -+ display_gdb_prompt (0); -+ } - } - } - -diff -Naurp insight-10.0.50.20200110.orig/gdb/symfile.h insight-10.0.50.20200110.new/gdb/symfile.h ---- insight-10.0.50.20200110.orig/gdb/symfile.h 2020-02-07 02:59:04.314420371 +0100 -+++ insight-10.0.50.20200110.new/gdb/symfile.h 2020-02-07 02:59:48.639861548 +0100 -@@ -541,6 +541,8 @@ extern void generic_load (const char *ar - /* build-id support. */ - extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); - extern void debug_print_missing (const char *binary, const char *debug); -+extern void debug_flush_missing (void); -+#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") - - /* From dwarf2read.c */ - diff --git a/insight-gdb-6.6-buildid-locate.patch b/insight-gdb-6.6-buildid-locate.patch deleted file mode 100644 index 63384ea..0000000 --- a/insight-gdb-6.6-buildid-locate.patch +++ /dev/null @@ -1,1369 +0,0 @@ -diff -Naurp insight-10.0.50.20200110.orig/bfd/libbfd.h insight-10.0.50.20200110.new/bfd/libbfd.h ---- insight-10.0.50.20200110.orig/bfd/libbfd.h 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/bfd/libbfd.h 2020-02-07 02:55:02.294012439 +0100 -@@ -132,7 +132,7 @@ static inline char * - bfd_strdup (const char *str) - { - size_t len = strlen (str) + 1; -- char *buf = bfd_malloc (len); -+ char *buf = (char *) bfd_malloc (len); - if (buf != NULL) - memcpy (buf, str, len); - return buf; -diff -Naurp insight-10.0.50.20200110.orig/bfd/libbfd-in.h insight-10.0.50.20200110.new/bfd/libbfd-in.h ---- insight-10.0.50.20200110.orig/bfd/libbfd-in.h 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/bfd/libbfd-in.h 2020-02-07 02:55:02.293012429 +0100 -@@ -127,7 +127,7 @@ static inline char * - bfd_strdup (const char *str) - { - size_t len = strlen (str) + 1; -- char *buf = bfd_malloc (len); -+ char *buf = (char *) bfd_malloc (len); - if (buf != NULL) - memcpy (buf, str, len); - return buf; -diff -Naurp insight-10.0.50.20200110.orig/gdb/build-id.c insight-10.0.50.20200110.new/gdb/build-id.c ---- insight-10.0.50.20200110.orig/gdb/build-id.c 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/build-id.c 2020-02-07 02:55:02.294012439 +0100 -@@ -24,13 +24,71 @@ - #include "gdbsupport/gdb_vecs.h" - #include "symfile.h" - #include "objfiles.h" -+#include -+#include "elf-bfd.h" -+#include "elf/common.h" -+#include "elf/external.h" -+#include "elf/internal.h" - #include "filenames.h" -+#include "gdb_bfd.h" -+#include "gdbcmd.h" - #include "gdbcore.h" -+#include "libbfd.h" -+#include "objfiles.h" -+#include "observable.h" -+#include "symfile.h" -+ -+#define BUILD_ID_VERBOSE_NONE 0 -+#define BUILD_ID_VERBOSE_FILENAMES 1 -+#define BUILD_ID_VERBOSE_BINARY_PARSE 2 -+static int build_id_verbose = BUILD_ID_VERBOSE_FILENAMES; -+static void -+show_build_id_verbose (struct ui_file *file, int from_tty, -+ struct cmd_list_element *c, const char *value) -+{ -+ fprintf_filtered (file, _("Verbosity level of the build-id locator is %s.\n"), -+ value); -+} -+/* Locate NT_GNU_BUILD_ID and return its matching debug filename. -+ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */ -+ -+static struct bfd_build_id * -+build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size) -+{ -+ bfd_byte *p; -+ -+ p = buf; -+ while (p < buf + size) -+ { -+ /* FIXME: bad alignment assumption. */ -+ Elf_External_Note *xnp = (Elf_External_Note *) p; -+ size_t namesz = H_GET_32 (templ, xnp->namesz); -+ size_t descsz = H_GET_32 (templ, xnp->descsz); -+ bfd_byte *descdata = (gdb_byte *) xnp->name + BFD_ALIGN (namesz, 4); -+ -+ if (H_GET_32 (templ, xnp->type) == NT_GNU_BUILD_ID -+ && namesz == sizeof "GNU" -+ && memcmp (xnp->name, "GNU", sizeof "GNU") == 0) -+ { -+ size_t sz = descsz; -+ gdb_byte *data = (gdb_byte *) descdata; -+ struct bfd_build_id *retval; -+ -+ retval = (struct bfd_build_id *) xmalloc (sizeof *retval - 1 + sz); -+ retval->size = sz; -+ memcpy (retval->data, data, sz); -+ -+ return retval; -+ } -+ p = descdata + BFD_ALIGN (descsz, 4); -+ } -+ return NULL; -+} - - /* See build-id.h. */ - - const struct bfd_build_id * --build_id_bfd_get (bfd *abfd) -+build_id_bfd_shdr_get (bfd *abfd) - { - if (!bfd_check_format (abfd, bfd_object) - && !bfd_check_format (abfd, bfd_core)) -@@ -43,6 +101,348 @@ build_id_bfd_get (bfd *abfd) - return NULL; - } - -+/* Core files may have missing (corrupt) SHDR but PDHR is correct there. -+ bfd_elf_bfd_from_remote_memory () has too much overhead by -+ allocating/reading all the available ELF PT_LOADs. */ -+ -+static struct bfd_build_id * -+build_id_phdr_get (bfd *templ, bfd_vma loadbase, unsigned e_phnum, -+ Elf_Internal_Phdr *i_phdr) -+{ -+ int i; -+ struct bfd_build_id *retval = NULL; -+ -+ for (i = 0; i < e_phnum; i++) -+ if (i_phdr[i].p_type == PT_NOTE && i_phdr[i].p_filesz > 0) -+ { -+ Elf_Internal_Phdr *hdr = &i_phdr[i]; -+ gdb_byte *buf; -+ int err; -+ -+ buf = (gdb_byte *) xmalloc (hdr->p_filesz); -+ err = target_read_memory (loadbase + i_phdr[i].p_vaddr, buf, -+ hdr->p_filesz); -+ if (err == 0) -+ retval = build_id_buf_get (templ, buf, hdr->p_filesz); -+ else -+ retval = NULL; -+ xfree (buf); -+ if (retval != NULL) -+ break; -+ } -+ return retval; -+} -+ -+/* First we validate the file by reading in the ELF header and checking -+ the magic number. */ -+ -+static inline bfd_boolean -+elf_file_p (Elf64_External_Ehdr *x_ehdrp64) -+{ -+ gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr)); -+ gdb_assert (offsetof (Elf64_External_Ehdr, e_ident) -+ == offsetof (Elf32_External_Ehdr, e_ident)); -+ gdb_assert (sizeof (((Elf64_External_Ehdr *) 0)->e_ident) -+ == sizeof (((Elf32_External_Ehdr *) 0)->e_ident)); -+ -+ return ((x_ehdrp64->e_ident[EI_MAG0] == ELFMAG0) -+ && (x_ehdrp64->e_ident[EI_MAG1] == ELFMAG1) -+ && (x_ehdrp64->e_ident[EI_MAG2] == ELFMAG2) -+ && (x_ehdrp64->e_ident[EI_MAG3] == ELFMAG3)); -+} -+ -+/* Translate an ELF file header in external format into an ELF file header in -+ internal format. */ -+ -+#define H_GET_WORD(bfd, ptr) (is64 ? H_GET_64 (bfd, (ptr)) \ -+ : H_GET_32 (bfd, (ptr))) -+#define H_GET_SIGNED_WORD(bfd, ptr) (is64 ? H_GET_S64 (bfd, (ptr)) \ -+ : H_GET_S32 (bfd, (ptr))) -+ -+static void -+elf_swap_ehdr_in (bfd *abfd, -+ const Elf64_External_Ehdr *src64, -+ Elf_Internal_Ehdr *dst) -+{ -+ int is64 = bfd_get_arch_size (abfd) == 64; -+#define SRC(field) (is64 ? src64->field \ -+ : ((const Elf32_External_Ehdr *) src64)->field) -+ -+ int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; -+ memcpy (dst->e_ident, SRC (e_ident), EI_NIDENT); -+ dst->e_type = H_GET_16 (abfd, SRC (e_type)); -+ dst->e_machine = H_GET_16 (abfd, SRC (e_machine)); -+ dst->e_version = H_GET_32 (abfd, SRC (e_version)); -+ if (signed_vma) -+ dst->e_entry = H_GET_SIGNED_WORD (abfd, SRC (e_entry)); -+ else -+ dst->e_entry = H_GET_WORD (abfd, SRC (e_entry)); -+ dst->e_phoff = H_GET_WORD (abfd, SRC (e_phoff)); -+ dst->e_shoff = H_GET_WORD (abfd, SRC (e_shoff)); -+ dst->e_flags = H_GET_32 (abfd, SRC (e_flags)); -+ dst->e_ehsize = H_GET_16 (abfd, SRC (e_ehsize)); -+ dst->e_phentsize = H_GET_16 (abfd, SRC (e_phentsize)); -+ dst->e_phnum = H_GET_16 (abfd, SRC (e_phnum)); -+ dst->e_shentsize = H_GET_16 (abfd, SRC (e_shentsize)); -+ dst->e_shnum = H_GET_16 (abfd, SRC (e_shnum)); -+ dst->e_shstrndx = H_GET_16 (abfd, SRC (e_shstrndx)); -+ -+#undef SRC -+} -+ -+/* Translate an ELF program header table entry in external format into an -+ ELF program header table entry in internal format. */ -+ -+static void -+elf_swap_phdr_in (bfd *abfd, -+ const Elf64_External_Phdr *src64, -+ Elf_Internal_Phdr *dst) -+{ -+ int is64 = bfd_get_arch_size (abfd) == 64; -+#define SRC(field) (is64 ? src64->field \ -+ : ((const Elf32_External_Phdr *) src64)->field) -+ -+ int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma; -+ -+ dst->p_type = H_GET_32 (abfd, SRC (p_type)); -+ dst->p_flags = H_GET_32 (abfd, SRC (p_flags)); -+ dst->p_offset = H_GET_WORD (abfd, SRC (p_offset)); -+ if (signed_vma) -+ { -+ dst->p_vaddr = H_GET_SIGNED_WORD (abfd, SRC (p_vaddr)); -+ dst->p_paddr = H_GET_SIGNED_WORD (abfd, SRC (p_paddr)); -+ } -+ else -+ { -+ dst->p_vaddr = H_GET_WORD (abfd, SRC (p_vaddr)); -+ dst->p_paddr = H_GET_WORD (abfd, SRC (p_paddr)); -+ } -+ dst->p_filesz = H_GET_WORD (abfd, SRC (p_filesz)); -+ dst->p_memsz = H_GET_WORD (abfd, SRC (p_memsz)); -+ dst->p_align = H_GET_WORD (abfd, SRC (p_align)); -+ -+#undef SRC -+} -+ -+#undef H_GET_SIGNED_WORD -+#undef H_GET_WORD -+ -+static Elf_Internal_Phdr * -+elf_get_phdr (bfd *templ, bfd_vma ehdr_vma, unsigned *e_phnum_pointer, -+ bfd_vma *loadbase_pointer) -+{ -+ /* sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr) */ -+ Elf64_External_Ehdr x_ehdr64; /* Elf file header, external form */ -+ Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */ -+ bfd_size_type x_phdrs_size; -+ gdb_byte *x_phdrs_ptr; -+ Elf_Internal_Phdr *i_phdrs; -+ int err; -+ unsigned int i; -+ bfd_vma loadbase; -+ int loadbase_set; -+ -+ gdb_assert (templ != NULL); -+ gdb_assert (sizeof (Elf64_External_Ehdr) >= sizeof (Elf32_External_Ehdr)); -+ -+ /* Read in the ELF header in external format. */ -+ err = target_read_memory (ehdr_vma, (bfd_byte *) &x_ehdr64, sizeof x_ehdr64); -+ if (err) -+ { -+ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) -+ warning (_("build-id: Error reading ELF header at address 0x%lx"), -+ (unsigned long) ehdr_vma); -+ return NULL; -+ } -+ -+ /* Now check to see if we have a valid ELF file, and one that BFD can -+ make use of. The magic number must match, the address size ('class') -+ and byte-swapping must match our XVEC entry. */ -+ -+ if (! elf_file_p (&x_ehdr64) -+ || x_ehdr64.e_ident[EI_VERSION] != EV_CURRENT -+ || !((bfd_get_arch_size (templ) == 64 -+ && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS64) -+ || (bfd_get_arch_size (templ) == 32 -+ && x_ehdr64.e_ident[EI_CLASS] == ELFCLASS32))) -+ { -+ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) -+ warning (_("build-id: Unrecognized ELF header at address 0x%lx"), -+ (unsigned long) ehdr_vma); -+ return NULL; -+ } -+ -+ /* Check that file's byte order matches xvec's */ -+ switch (x_ehdr64.e_ident[EI_DATA]) -+ { -+ case ELFDATA2MSB: /* Big-endian */ -+ if (! bfd_header_big_endian (templ)) -+ { -+ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) -+ warning (_("build-id: Unrecognized " -+ "big-endian ELF header at address 0x%lx"), -+ (unsigned long) ehdr_vma); -+ return NULL; -+ } -+ break; -+ case ELFDATA2LSB: /* Little-endian */ -+ if (! bfd_header_little_endian (templ)) -+ { -+ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) -+ warning (_("build-id: Unrecognized " -+ "little-endian ELF header at address 0x%lx"), -+ (unsigned long) ehdr_vma); -+ return NULL; -+ } -+ break; -+ case ELFDATANONE: /* No data encoding specified */ -+ default: /* Unknown data encoding specified */ -+ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) -+ warning (_("build-id: Unrecognized " -+ "ELF header endianity at address 0x%lx"), -+ (unsigned long) ehdr_vma); -+ return NULL; -+ } -+ -+ elf_swap_ehdr_in (templ, &x_ehdr64, &i_ehdr); -+ -+ /* The file header tells where to find the program headers. -+ These are what we use to actually choose what to read. */ -+ -+ if (i_ehdr.e_phentsize != (bfd_get_arch_size (templ) == 64 -+ ? sizeof (Elf64_External_Phdr) -+ : sizeof (Elf32_External_Phdr)) -+ || i_ehdr.e_phnum == 0) -+ { -+ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) -+ warning (_("build-id: Invalid ELF program headers from the ELF header " -+ "at address 0x%lx"), (unsigned long) ehdr_vma); -+ return NULL; -+ } -+ -+ x_phdrs_size = (bfd_get_arch_size (templ) == 64 ? sizeof (Elf64_External_Phdr) -+ : sizeof (Elf32_External_Phdr)); -+ -+ i_phdrs = (Elf_Internal_Phdr *) xmalloc (i_ehdr.e_phnum * (sizeof *i_phdrs + x_phdrs_size)); -+ x_phdrs_ptr = (gdb_byte *) &i_phdrs[i_ehdr.e_phnum]; -+ err = target_read_memory (ehdr_vma + i_ehdr.e_phoff, (bfd_byte *) x_phdrs_ptr, -+ i_ehdr.e_phnum * x_phdrs_size); -+ if (err) -+ { -+ free (i_phdrs); -+ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) -+ warning (_("build-id: Error reading " -+ "ELF program headers at address 0x%lx"), -+ (unsigned long) (ehdr_vma + i_ehdr.e_phoff)); -+ return NULL; -+ } -+ -+ loadbase = ehdr_vma; -+ loadbase_set = 0; -+ for (i = 0; i < i_ehdr.e_phnum; ++i) -+ { -+ elf_swap_phdr_in (templ, (Elf64_External_Phdr *) -+ (x_phdrs_ptr + i * x_phdrs_size), &i_phdrs[i]); -+ /* IA-64 vDSO may have two mappings for one segment, where one mapping -+ is executable only, and one is read only. We must not use the -+ executable one (PF_R is the first one, PF_X the second one). */ -+ if (i_phdrs[i].p_type == PT_LOAD && (i_phdrs[i].p_flags & PF_R)) -+ { -+ /* Only the first PT_LOAD segment indicates the file bias. -+ Next segments may have P_VADDR arbitrarily higher. -+ If the first segment has P_VADDR zero any next segment must not -+ confuse us, the first one sets LOADBASE certainly enough. */ -+ if (!loadbase_set && i_phdrs[i].p_offset == 0) -+ { -+ loadbase = ehdr_vma - i_phdrs[i].p_vaddr; -+ loadbase_set = 1; -+ } -+ } -+ } -+ -+ if (build_id_verbose >= BUILD_ID_VERBOSE_BINARY_PARSE) -+ warning (_("build-id: Found ELF header at address 0x%lx, loadbase 0x%lx"), -+ (unsigned long) ehdr_vma, (unsigned long) loadbase); -+ -+ *e_phnum_pointer = i_ehdr.e_phnum; -+ *loadbase_pointer = loadbase; -+ return i_phdrs; -+} -+ -+/* BUILD_ID_ADDR_GET gets ADDR located somewhere in the object. -+ Find the first section before ADDR containing an ELF header. -+ We rely on the fact the sections from multiple files do not mix. -+ FIXME: We should check ADDR is contained _inside_ the section with possibly -+ missing content (P_FILESZ < P_MEMSZ). These omitted sections are currently -+ hidden by _BFD_ELF_MAKE_SECTION_FROM_PHDR. */ -+ -+static CORE_ADDR build_id_addr; -+struct build_id_addr_sect -+ { -+ struct build_id_addr_sect *next; -+ asection *sect; -+ }; -+static struct build_id_addr_sect *build_id_addr_sect; -+ -+static void build_id_addr_candidate (bfd *abfd, asection *sect, void *obj) -+{ -+ if (build_id_addr >= bfd_section_vma (sect)) -+ { -+ struct build_id_addr_sect *candidate; -+ -+ candidate = (struct build_id_addr_sect *) xmalloc (sizeof *candidate); -+ candidate->next = build_id_addr_sect; -+ build_id_addr_sect = candidate; -+ candidate->sect = sect; -+ } -+} -+ -+struct bfd_build_id * -+build_id_addr_get (CORE_ADDR addr) -+{ -+ struct build_id_addr_sect *candidate; -+ struct bfd_build_id *retval = NULL; -+ Elf_Internal_Phdr *i_phdr = NULL; -+ bfd_vma loadbase = 0; -+ unsigned e_phnum = 0; -+ -+ if (core_bfd == NULL) -+ return NULL; -+ -+ build_id_addr = addr; -+ gdb_assert (build_id_addr_sect == NULL); -+ bfd_map_over_sections (core_bfd, build_id_addr_candidate, NULL); -+ -+ /* Sections are sorted in the high-to-low VMAs order. -+ Stop the search on the first ELF header we find. -+ Do not continue the search even if it does not contain NT_GNU_BUILD_ID. */ -+ -+ for (candidate = build_id_addr_sect; candidate != NULL; -+ candidate = candidate->next) -+ { -+ i_phdr = elf_get_phdr (core_bfd, -+ bfd_section_vma (candidate->sect), -+ &e_phnum, &loadbase); -+ if (i_phdr != NULL) -+ break; -+ } -+ -+ if (i_phdr != NULL) -+ { -+ retval = build_id_phdr_get (core_bfd, loadbase, e_phnum, i_phdr); -+ xfree (i_phdr); -+ } -+ -+ while (build_id_addr_sect != NULL) -+ { -+ candidate = build_id_addr_sect; -+ build_id_addr_sect = candidate->next; -+ xfree (candidate); -+ } -+ -+ return retval; -+} -+ - /* See build-id.h. */ - - int -@@ -51,7 +451,7 @@ build_id_verify (bfd *abfd, size_t check - const struct bfd_build_id *found; - int retval = 0; - -- found = build_id_bfd_get (abfd); -+ found = build_id_bfd_shdr_get (abfd); - - if (found == NULL) - warning (_("File \"%s\" has no build-id, file skipped"), -@@ -66,56 +466,159 @@ build_id_verify (bfd *abfd, size_t check - return retval; - } - -+static char * -+link_resolve (const char *symlink, int level) -+{ -+ char buf[PATH_MAX + 1], *target, *retval; -+ ssize_t got; -+ -+ if (level > 10) -+ return xstrdup (symlink); -+ -+ got = readlink (symlink, buf, sizeof (buf)); -+ if (got < 0 || got >= sizeof (buf)) -+ return xstrdup (symlink); -+ buf[got] = '\0'; -+ -+ if (IS_ABSOLUTE_PATH (buf)) -+ target = xstrdup (buf); -+ else -+ { -+ const std::string dir (ldirname (symlink)); -+ -+ target = xstrprintf ("%s" -+#ifndef HAVE_DOS_BASED_FILE_SYSTEM -+ "/" -+#else /* HAVE_DOS_BASED_FILE_SYSTEM */ -+ "\\" -+#endif /* HAVE_DOS_BASED_FILE_SYSTEM */ -+ "%s", dir.c_str(), buf); -+ } -+ -+ retval = link_resolve (target, level + 1); -+ xfree (target); -+ return retval; -+} -+ - /* Helper for build_id_to_debug_bfd. LINK is a path to a potential - build-id-based separate debug file, potentially a symlink to the real file. - If the file exists and matches BUILD_ID, return a BFD reference to it. */ - - static gdb_bfd_ref_ptr --build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, -- const bfd_byte *build_id) -+build_id_to_debug_bfd_1 (const std::string &orig_link, size_t build_id_len, -+ const bfd_byte *build_id, char **link_return) - { -+ gdb_bfd_ref_ptr ret_bfd = {}; -+ std::string ret_link; -+ - if (separate_debug_file_debug) - { -- printf_unfiltered (_(" Trying %s..."), link.c_str ()); -+ printf_unfiltered (_(" Trying %s..."), orig_link.c_str ()); - gdb_flush (gdb_stdout); - } - -- /* lrealpath() is expensive even for the usually non-existent files. */ -- gdb::unique_xmalloc_ptr filename; -- if (access (link.c_str (), F_OK) == 0) -- filename.reset (lrealpath (link.c_str ())); -- -- if (filename == NULL) -+ for (unsigned seqno = 0;; seqno++) - { -- if (separate_debug_file_debug) -- printf_unfiltered (_(" no, unable to compute real path\n")); -+ std::string link = orig_link; - -- return {}; -- } -+ if (seqno > 0) -+ { -+ /* There can be multiple build-id symlinks pointing to real files -+ with the same build-id (such as hard links). Some of the real -+ files may not be installed. */ - -- /* We expect to be silent on the non-existing files. */ -- gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1); -+ string_appendf (link, ".%u", seqno); -+ } - -- if (debug_bfd == NULL) -- { -- if (separate_debug_file_debug) -- printf_unfiltered (_(" no, unable to open.\n")); -+ ret_link = link; -+ -+ struct stat statbuf_trash; -+ -+ /* `access' automatically dereferences LINK. */ -+ if (lstat (link.c_str (), &statbuf_trash) != 0) -+ { -+ /* Stop increasing SEQNO. */ -+ break; -+ } -+ -+ /* lrealpath() is expensive even for the usually non-existent files. */ -+ gdb::unique_xmalloc_ptr filename; -+ -+ if (access (link.c_str (), F_OK) == 0) -+ filename.reset (lrealpath (link.c_str ())); -+ -+ if (filename == NULL) -+ { -+ if (separate_debug_file_debug) -+ printf_unfiltered (_(" no, unable to compute real path\n")); -+ -+ continue; -+ } -+ -+ /* We expect to be silent on the non-existing files. */ -+ gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1); -+ -+ if (debug_bfd == NULL) -+ { -+ if (separate_debug_file_debug) -+ printf_unfiltered (_(" no, unable to open.\n")); - -- return {}; -+ continue; -+ } -+ -+ if (!build_id_verify (debug_bfd.get(), build_id_len, build_id)) -+ { -+ if (separate_debug_file_debug) -+ printf_unfiltered (_(" no, build-id does not match.\n")); -+ -+ continue; -+ } -+ -+ ret_bfd = debug_bfd; -+ break; - } - -- if (!build_id_verify (debug_bfd.get(), build_id_len, build_id)) -+ std::string link_all; -+ -+ if (ret_bfd != NULL) - { - if (separate_debug_file_debug) -- printf_unfiltered (_(" no, build-id does not match.\n")); -- -- return {}; -+ printf_unfiltered (_(" yes!\n")); -+ } -+ else -+ { -+ /* If none of the real files is found report as missing file -+ always the non-.%u-suffixed file. */ -+ std::string link0 = orig_link; -+ -+ /* If the symlink has target request to install the target. -+ BASE-debuginfo.rpm contains the symlink but BASE.rpm may be missing. -+ https://bugzilla.redhat.com/show_bug.cgi?id=981154 */ -+ std::string link0_resolved (link_resolve (link0.c_str (), 0)); -+ -+ if (link_all.empty ()) -+ link_all = link0_resolved; -+ else -+ { -+ /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with -+ its possible use as an argument for installation command. */ -+ link_all += " " + link0_resolved; -+ } - } - -- if (separate_debug_file_debug) -- printf_unfiltered (_(" yes!\n")); -+ if (link_return != NULL) -+ { -+ if (ret_bfd != NULL) -+ { -+ *link_return = xstrdup (ret_link.c_str ()); -+ } -+ else -+ { -+ *link_return = xstrdup (link_all.c_str ()); -+ } -+ } - -- return debug_bfd; -+ return ret_bfd; - } - - /* Common code for finding BFDs of a given build-id. This function -@@ -124,7 +627,7 @@ build_id_to_debug_bfd_1 (const std::stri - - static gdb_bfd_ref_ptr - build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, -- const char *suffix) -+ const char *suffix, char **link_return) - { - /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will - cause "/.build-id/..." lookups. */ -@@ -147,16 +650,17 @@ build_id_to_bfd_suffix (size_t build_id_ - if (size > 0) - { - size--; -- string_appendf (link, "%02x/", (unsigned) *data++); -+ string_appendf (link, "%02x", (unsigned) *data++); - } -- -+ if (size > 0) -+ link += "/"; - while (size-- > 0) - string_appendf (link, "%02x", (unsigned) *data++); - - link += suffix; - - gdb_bfd_ref_ptr debug_bfd -- = build_id_to_debug_bfd_1 (link, build_id_len, build_id); -+ = build_id_to_debug_bfd_1 (link, build_id_len, build_id, link_return); - if (debug_bfd != NULL) - return debug_bfd; - -@@ -170,7 +674,8 @@ build_id_to_bfd_suffix (size_t build_id_ - if (strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) != 0) - { - link = gdb_sysroot + link; -- debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id); -+ debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id, -+ link_return); - if (debug_bfd != NULL) - return debug_bfd; - } -@@ -179,38 +684,208 @@ build_id_to_bfd_suffix (size_t build_id_ - return {}; - } - -+char * -+build_id_to_filename (const struct bfd_build_id *build_id, char **link_return) -+{ -+ gdb_bfd_ref_ptr abfd; -+ char *result; -+ -+ abfd = build_id_to_exec_bfd (build_id->size, build_id->data, link_return); -+ if (abfd == NULL) -+ return NULL; -+ -+ result = xstrdup (bfd_get_filename (abfd.get ())); -+ return result; -+} -+ -+/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages -+ Try to install the hash file ... -+ avoidance. */ -+ -+struct missing_filepair -+ { -+ char *binary; -+ char *debug; -+ char data[1]; -+ }; -+ -+static struct htab *missing_filepair_hash; -+static struct obstack missing_filepair_obstack; -+ -+static void * -+missing_filepair_xcalloc (size_t nmemb, size_t nmemb_size) -+{ -+ void *retval; -+ size_t size = nmemb * nmemb_size; -+ -+ retval = obstack_alloc (&missing_filepair_obstack, size); -+ memset (retval, 0, size); -+ return retval; -+} -+ -+static hashval_t -+missing_filepair_hash_func (const struct missing_filepair *elem) -+{ -+ hashval_t retval = 0; -+ -+ retval ^= htab_hash_string (elem->binary); -+ if (elem->debug != NULL) -+ retval ^= htab_hash_string (elem->debug); -+ -+ return retval; -+} -+ -+static int -+missing_filepair_eq (const struct missing_filepair *elem1, -+ const struct missing_filepair *elem2) -+{ -+ return strcmp (elem1->binary, elem2->binary) == 0 -+ && ((elem1->debug == NULL) == (elem2->debug == NULL)) -+ && (elem1->debug == NULL || strcmp (elem1->debug, elem2->debug) == 0); -+} -+ -+static void -+missing_filepair_change (void) -+{ -+ if (missing_filepair_hash != NULL) -+ { -+ obstack_free (&missing_filepair_obstack, NULL); -+ /* All their memory came just from missing_filepair_OBSTACK. */ -+ missing_filepair_hash = NULL; -+ } -+} -+ -+static void -+debug_print_executable_changed (void) -+{ -+ missing_filepair_change (); -+} -+ -+/* Notify user the file BINARY with (possibly NULL) associated separate debug -+ information file DEBUG is missing. DEBUG may or may not be the build-id -+ file such as would be: -+ /usr/lib/debug/.build-id/dd/b1d2ce632721c47bb9e8679f369e2295ce71be.debug -+ */ -+ -+void -+debug_print_missing (const char *binary, const char *debug) -+{ -+ size_t binary_len0 = strlen (binary) + 1; -+ size_t debug_len0 = debug ? strlen (debug) + 1 : 0; -+ struct missing_filepair missing_filepair_find; -+ struct missing_filepair *missing_filepair; -+ struct missing_filepair **slot; -+ -+ if (build_id_verbose < BUILD_ID_VERBOSE_FILENAMES) -+ return; -+ -+ if (missing_filepair_hash == NULL) -+ { -+ obstack_init (&missing_filepair_obstack); -+ missing_filepair_hash = htab_create_alloc (64, -+ (hashval_t (*) (const void *)) missing_filepair_hash_func, -+ (int (*) (const void *, const void *)) missing_filepair_eq, NULL, -+ missing_filepair_xcalloc, NULL); -+ } -+ -+ /* Use MISSING_FILEPAIR_FIND first instead of calling obstack_alloc with -+ obstack_free in the case of a (rare) match. The problem is ALLOC_F for -+ MISSING_FILEPAIR_HASH allocates from MISSING_FILEPAIR_OBSTACK maintenance -+ structures for MISSING_FILEPAIR_HASH. Calling obstack_free would possibly -+ not to free only MISSING_FILEPAIR but also some such structures (allocated -+ during the htab_find_slot call). */ -+ -+ missing_filepair_find.binary = (char *) binary; -+ missing_filepair_find.debug = (char *) debug; -+ slot = (struct missing_filepair **) htab_find_slot (missing_filepair_hash, -+ &missing_filepair_find, -+ INSERT); -+ -+ /* While it may be still printed duplicitely with the missing debuginfo file -+ * it is due to once printing about the binary file build-id link and once -+ * about the .debug file build-id link as both the build-id symlinks are -+ * located in the debuginfo package. */ -+ -+ if (*slot != NULL) -+ return; -+ -+ missing_filepair = (struct missing_filepair *) obstack_alloc (&missing_filepair_obstack, -+ sizeof (*missing_filepair) - 1 -+ + binary_len0 + debug_len0); -+ missing_filepair->binary = missing_filepair->data; -+ memcpy (missing_filepair->binary, binary, binary_len0); -+ if (debug != NULL) -+ { -+ missing_filepair->debug = missing_filepair->binary + binary_len0; -+ memcpy (missing_filepair->debug, debug, debug_len0); -+ } -+ else -+ missing_filepair->debug = NULL; -+ -+ *slot = missing_filepair; -+ -+ /* We do not collect and flush these messages as each such message -+ already requires its own separate lines. */ -+ -+ fprintf_unfiltered (gdb_stdlog, -+ _("Missing separate debuginfo for %s\n"), binary); -+ if (debug != NULL) -+ fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"), -+ debug); -+} -+ - /* See build-id.h. */ - - gdb_bfd_ref_ptr --build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) -+build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id, -+ char **link_return) - { -- return build_id_to_bfd_suffix (build_id_len, build_id, ".debug"); -+ return build_id_to_bfd_suffix (build_id_len, build_id, ".debug", -+ link_return); - } - - /* See build-id.h. */ - - gdb_bfd_ref_ptr --build_id_to_exec_bfd (size_t build_id_len, const bfd_byte *build_id) -+build_id_to_exec_bfd (size_t build_id_len, const bfd_byte *build_id, -+ char **link_return) - { -- return build_id_to_bfd_suffix (build_id_len, build_id, ""); -+ return build_id_to_bfd_suffix (build_id_len, build_id, "", link_return); - } - - /* See build-id.h. */ - - std::string --find_separate_debug_file_by_buildid (struct objfile *objfile) -+find_separate_debug_file_by_buildid (struct objfile *objfile, -+ gdb::unique_xmalloc_ptr *build_id_filename_return) - { - const struct bfd_build_id *build_id; - -- build_id = build_id_bfd_get (objfile->obfd); -+ if (build_id_filename_return) -+ *build_id_filename_return = NULL; -+ -+ build_id = build_id_bfd_shdr_get (objfile->obfd); - if (build_id != NULL) - { - if (separate_debug_file_debug) - printf_unfiltered (_("\nLooking for separate debug info (build-id) for " - "%s\n"), objfile_name (objfile)); - -+ char *build_id_filename_cstr = NULL; - gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size, -- build_id->data)); -+ build_id->data, -+ (!build_id_filename_return ? NULL : &build_id_filename_cstr))); -+ if (build_id_filename_return) -+ { -+ if (!build_id_filename_cstr) -+ gdb_assert (!*build_id_filename_return); -+ else -+ { -+ *build_id_filename_return = gdb::unique_xmalloc_ptr (build_id_filename_cstr); -+ build_id_filename_cstr = NULL; -+ } -+ } -+ - /* Prevent looping on a stripped .debug file. */ - if (abfd != NULL - && filename_cmp (bfd_get_filename (abfd.get ()), -@@ -223,3 +898,21 @@ find_separate_debug_file_by_buildid (str - - return std::string (); - } -+ -+extern void _initialize_build_id (void); -+ -+void -+_initialize_build_id (void) -+{ -+ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose, -+ _("\ -+Set debugging level of the build-id locator."), _("\ -+Show debugging level of the build-id locator."), _("\ -+Level 1 (default) enables printing the missing debug filenames,\n\ -+level 2 also prints the parsing of binaries to find the identificators."), -+ NULL, -+ show_build_id_verbose, -+ &setlist, &showlist); -+ -+ gdb::observers::executable_changed.attach (debug_print_executable_changed); -+} -diff -Naurp insight-10.0.50.20200110.orig/gdb/build-id.h insight-10.0.50.20200110.new/gdb/build-id.h ---- insight-10.0.50.20200110.orig/gdb/build-id.h 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/build-id.h 2020-02-07 02:55:02.294012439 +0100 -@@ -23,9 +23,10 @@ - #include "gdb_bfd.h" - #include "gdbsupport/rsp-low.h" - --/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */ -+/* Separate debuginfo files have corrupted PHDR but SHDR is correct there. -+ Locate NT_GNU_BUILD_ID from ABFD and return its content. */ - --extern const struct bfd_build_id *build_id_bfd_get (bfd *abfd); -+extern const struct bfd_build_id *build_id_bfd_shdr_get (bfd *abfd); - - /* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value. - Otherwise, issue a warning and return false. */ -@@ -38,21 +39,26 @@ extern int build_id_verify (bfd *abfd, - can be found, return NULL. */ - - extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len, -- const bfd_byte *build_id); -+ const bfd_byte *build_id, -+ char **link_return); -+ -+extern char *build_id_to_filename (const struct bfd_build_id *build_id, -+ char **link_return); - - /* Find and open a BFD for an executable file given a build-id. If no BFD - can be found, return NULL. The returned reference to the BFD must be - released by the caller. */ - - extern gdb_bfd_ref_ptr build_id_to_exec_bfd (size_t build_id_len, -- const bfd_byte *build_id); -+ const bfd_byte *build_id, -+ char **link_return); - - /* Find the separate debug file for OBJFILE, by using the build-id - associated with OBJFILE's BFD. If successful, returns the file name for the - separate debug file, otherwise, return an empty string. */ - --extern std::string find_separate_debug_file_by_buildid -- (struct objfile *objfile); -+extern std::string find_separate_debug_file_by_buildid (struct objfile *objfile, -+ gdb::unique_xmalloc_ptr *build_id_filename_return); - - /* Return an hex-string representation of BUILD_ID. */ - -diff -Naurp insight-10.0.50.20200110.orig/gdb/coffread.c insight-10.0.50.20200110.new/gdb/coffread.c ---- insight-10.0.50.20200110.orig/gdb/coffread.c 2020-01-10 12:05:27.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/coffread.c 2020-02-07 02:55:02.295012449 +0100 -@@ -709,7 +709,8 @@ coff_symfile_read (struct objfile *objfi - /* Try to add separate debug file if no symbols table found. */ - if (!objfile_has_partial_symbols (objfile)) - { -- std::string debugfile = find_separate_debug_file_by_buildid (objfile); -+ std::string debugfile = find_separate_debug_file_by_buildid (objfile, -+ NULL); - - if (debugfile.empty ()) - debugfile = find_separate_debug_file_by_debuglink (objfile); -diff -Naurp insight-10.0.50.20200110.orig/gdb/corelow.c insight-10.0.50.20200110.new/gdb/corelow.c ---- insight-10.0.50.20200110.orig/gdb/corelow.c 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/corelow.c 2020-02-07 02:55:02.295012449 +0100 -@@ -22,6 +22,10 @@ - #include - #include - #include "frame.h" /* required by inferior.h */ -+#include "auxv.h" -+#include "build-id.h" -+#include "elf/common.h" -+#include "gdbcmd.h" - #include "inferior.h" - #include "infrun.h" - #include "symtab.h" -@@ -323,6 +327,8 @@ add_to_thread_list (bfd *abfd, asection - inferior_ptid = ptid; /* Yes, make it current. */ - } - -+static bool build_id_core_loads = true; -+ - /* Issue a message saying we have no core to debug, if FROM_TTY. */ - - static void -@@ -359,19 +365,25 @@ core_file_command (const char *filename, - static void - locate_exec_from_corefile_build_id (bfd *abfd, int from_tty) - { -- const bfd_build_id *build_id = build_id_bfd_get (abfd); -+ const bfd_build_id *build_id = build_id_bfd_shdr_get (abfd); - if (build_id == nullptr) - return; - -+ char *build_id_filename; - gdb_bfd_ref_ptr execbfd -- = build_id_to_exec_bfd (build_id->size, build_id->data); -+ = build_id_to_exec_bfd (build_id->size, build_id->data, -+ &build_id_filename); - - if (execbfd != nullptr) - { - exec_file_attach (bfd_get_filename (execbfd.get ()), from_tty); - symbol_file_add_main (bfd_get_filename (execbfd.get ()), - symfile_add_flag (from_tty ? SYMFILE_VERBOSE : 0)); -+ if (symfile_objfile != NULL) -+ symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; - } -+ else -+ debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename); - } - - /* See gdbcore.h. */ -@@ -998,4 +1010,11 @@ void - _initialize_corelow (void) - { - add_target (core_target_info, core_target_open, filename_completer); -+ -+ add_setshow_boolean_cmd ("build-id-core-loads", class_files, -+ &build_id_core_loads, _("\ -+Set whether CORE-FILE loads the build-id associated files automatically."), _("\ -+Show whether CORE-FILE loads the build-id associated files automatically."), -+ NULL, NULL, NULL, -+ &setlist, &showlist); - } -diff -Naurp insight-10.0.50.20200110.orig/gdb/doc/gdb.texinfo insight-10.0.50.20200110.new/gdb/doc/gdb.texinfo ---- insight-10.0.50.20200110.orig/gdb/doc/gdb.texinfo 2020-02-07 02:53:11.078909328 +0100 -+++ insight-10.0.50.20200110.new/gdb/doc/gdb.texinfo 2020-02-07 02:55:02.302012519 +0100 -@@ -20862,6 +20862,27 @@ information files. - - @end table - -+You can also adjust the current verbosity of the @dfn{build id} locating. -+ -+@table @code -+ -+@kindex set build-id-verbose -+@item set build-id-verbose 0 -+No additional messages are printed. -+ -+@item set build-id-verbose 1 -+Missing separate debug filenames are printed. -+ -+@item set build-id-verbose 2 -+Missing separate debug filenames are printed and also all the parsing of the -+binaries to find their @dfn{build id} content is printed. -+ -+@kindex show build-id-verbose -+@item show build-id-verbose -+Show the current verbosity value for the @dfn{build id} content locating. -+ -+@end table -+ - @cindex @code{.gnu_debuglink} sections - @cindex debug link sections - A debug link is a special section of the executable file named -diff -Naurp insight-10.0.50.20200110.orig/gdb/dwarf2read.c insight-10.0.50.20200110.new/gdb/dwarf2read.c ---- insight-10.0.50.20200110.orig/gdb/dwarf2read.c 2020-02-07 02:53:12.273921168 +0100 -+++ insight-10.0.50.20200110.new/gdb/dwarf2read.c 2020-02-07 02:55:02.304012539 +0100 -@@ -2709,7 +2709,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_o - } - - if (dwz_bfd == NULL) -- dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid); -+ dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid, NULL); - - if (dwz_bfd == NULL) - error (_("could not find '.gnu_debugaltlink' file for %s"), -@@ -6265,7 +6265,7 @@ get_gdb_index_contents_from_section (obj - static gdb::array_view - get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_objfile *dwarf2_obj) - { -- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd); -+ const bfd_build_id *build_id = build_id_bfd_shdr_get (obj->obfd); - if (build_id == nullptr) - return {}; - -@@ -6278,7 +6278,7 @@ get_gdb_index_contents_from_cache (objfi - static gdb::array_view - get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz) - { -- const bfd_build_id *build_id = build_id_bfd_get (dwz->dwz_bfd.get ()); -+ const bfd_build_id *build_id = build_id_bfd_shdr_get (dwz->dwz_bfd.get ()); - if (build_id == nullptr) - return {}; - -diff -Naurp insight-10.0.50.20200110.orig/gdb/dwarf-index-cache.c insight-10.0.50.20200110.new/gdb/dwarf-index-cache.c ---- insight-10.0.50.20200110.orig/gdb/dwarf-index-cache.c 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/dwarf-index-cache.c 2020-02-07 02:55:02.302012519 +0100 -@@ -94,7 +94,7 @@ index_cache::store (struct dwarf2_per_ob - return; - - /* Get build id of objfile. */ -- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd); -+ const bfd_build_id *build_id = build_id_bfd_shdr_get (obj->obfd); - if (build_id == nullptr) - { - if (debug_index_cache) -@@ -112,7 +112,8 @@ index_cache::store (struct dwarf2_per_ob - - if (dwz != nullptr) - { -- const bfd_build_id *dwz_build_id = build_id_bfd_get (dwz->dwz_bfd.get ()); -+ const bfd_build_id *dwz_build_id -+ = build_id_bfd_shdr_get (dwz->dwz_bfd.get ()); - - if (dwz_build_id == nullptr) - { -diff -Naurp insight-10.0.50.20200110.orig/gdb/elfread.c insight-10.0.50.20200110.new/gdb/elfread.c ---- insight-10.0.50.20200110.orig/gdb/elfread.c 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/elfread.c 2020-02-07 02:55:02.305012549 +0100 -@@ -1299,7 +1299,9 @@ elf_symfile_read (struct objfile *objfil - && objfile->separate_debug_objfile == NULL - && objfile->separate_debug_objfile_backlink == NULL) - { -- std::string debugfile = find_separate_debug_file_by_buildid (objfile); -+ gdb::unique_xmalloc_ptr build_id_filename; -+ std::string debugfile -+ = find_separate_debug_file_by_buildid (objfile, &build_id_filename); - - if (debugfile.empty ()) - debugfile = find_separate_debug_file_by_debuglink (objfile); -@@ -1311,8 +1313,12 @@ elf_symfile_read (struct objfile *objfil - symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (), - symfile_flags, objfile); - } -- else -- has_dwarf2 = false; -+ /* Check if any separate debug info has been extracted out. */ -+ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink") -+ != NULL) -+ debug_print_missing (objfile_name (objfile), build_id_filename.get ()); -+ else -+ has_dwarf2 = false; - } - - /* Read the CTF section only if there is no DWARF info. */ -diff -Naurp insight-10.0.50.20200110.orig/gdb/objfiles.h insight-10.0.50.20200110.new/gdb/objfiles.h ---- insight-10.0.50.20200110.orig/gdb/objfiles.h 2020-01-10 12:05:27.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/objfiles.h 2020-02-07 02:55:02.305012549 +0100 -@@ -655,6 +655,10 @@ struct objfile_deleter - - typedef std::unique_ptr objfile_up; - -+/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */ -+ -+#define OBJF_BUILD_ID_CORE_LOADED static_cast(1 << 12) -+ - /* Declarations for functions defined in objfiles.c */ - - extern struct gdbarch *get_objfile_arch (const struct objfile *); -diff -Naurp insight-10.0.50.20200110.orig/gdb/python/py-objfile.c insight-10.0.50.20200110.new/gdb/python/py-objfile.c ---- insight-10.0.50.20200110.orig/gdb/python/py-objfile.c 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/python/py-objfile.c 2020-02-07 02:55:02.305012549 +0100 -@@ -132,7 +132,7 @@ objfpy_get_build_id (PyObject *self, voi - - try - { -- build_id = build_id_bfd_get (objfile->obfd); -+ build_id = build_id_bfd_shdr_get (objfile->obfd); - } - catch (const gdb_exception &except) - { -@@ -600,7 +600,7 @@ objfpy_lookup_objfile_by_build_id (const - /* Don't return separate debug files. */ - if (objfile->separate_debug_objfile_backlink != NULL) - continue; -- obfd_build_id = build_id_bfd_get (objfile->obfd); -+ obfd_build_id = build_id_bfd_shdr_get (objfile->obfd); - if (obfd_build_id == NULL) - continue; - if (objfpy_build_id_matches (obfd_build_id, build_id)) -diff -Naurp insight-10.0.50.20200110.orig/gdb/solib-svr4.c insight-10.0.50.20200110.new/gdb/solib-svr4.c ---- insight-10.0.50.20200110.orig/gdb/solib-svr4.c 2020-01-10 12:05:27.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/solib-svr4.c 2020-02-07 02:55:02.305012549 +0100 -@@ -45,6 +45,7 @@ - #include "auxv.h" - #include "gdb_bfd.h" - #include "probe.h" -+#include "build-id.h" - - static struct link_map_offsets *svr4_fetch_link_map_offsets (void); - static int svr4_have_link_map_offsets (void); -@@ -1344,9 +1345,51 @@ svr4_read_so_list (svr4_info *info, CORE - continue; - } - -- strncpy (newobj->so_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1); -- newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; -- strcpy (newobj->so_original_name, newobj->so_name); -+ { -+ struct bfd_build_id *build_id; -+ -+ strncpy (newobj->so_original_name, buffer.get (), SO_NAME_MAX_PATH_SIZE - 1); -+ newobj->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; -+ /* May get overwritten below. */ -+ strcpy (newobj->so_name, newobj->so_original_name); -+ -+ build_id = build_id_addr_get (((lm_info_svr4 *) newobj->lm_info)->l_ld); -+ if (build_id != NULL) -+ { -+ char *name, *build_id_filename; -+ -+ /* Missing the build-id matching separate debug info file -+ would be handled while SO_NAME gets loaded. */ -+ name = build_id_to_filename (build_id, &build_id_filename); -+ if (name != NULL) -+ { -+ strncpy (newobj->so_name, name, SO_NAME_MAX_PATH_SIZE - 1); -+ newobj->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0'; -+ xfree (name); -+ } -+ else -+ { -+ debug_print_missing (newobj->so_name, build_id_filename); -+ -+ /* In the case the main executable was found according to -+ its build-id (from a core file) prevent loading -+ a different build of a library with accidentally the -+ same SO_NAME. -+ -+ It suppresses bogus backtraces (and prints "??" there -+ instead) if the on-disk files no longer match the -+ running program version. */ -+ -+ if (symfile_objfile != NULL -+ && (symfile_objfile->flags -+ & OBJF_BUILD_ID_CORE_LOADED) != 0) -+ newobj->so_name[0] = 0; -+ } -+ -+ xfree (build_id_filename); -+ xfree (build_id); -+ } -+ } - - /* If this entry has no name, or its name matches the name - for the main executable, don't include it in the list. */ -diff -Naurp insight-10.0.50.20200110.orig/gdb/symfile.h insight-10.0.50.20200110.new/gdb/symfile.h ---- insight-10.0.50.20200110.orig/gdb/symfile.h 2020-01-10 12:05:27.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/symfile.h 2020-02-07 02:55:02.305012549 +0100 -@@ -531,12 +531,17 @@ void expand_symtabs_matching - void map_symbol_filenames (symbol_filename_ftype *fun, void *data, - int need_fullname); - -+ - /* Target-agnostic function to load the sections of an executable into memory. - - ARGS should be in the form "EXECUTABLE [OFFSET]", where OFFSET is an - optional offset to apply to each section. */ - extern void generic_load (const char *args, int from_tty); - -+/* build-id support. */ -+extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); -+extern void debug_print_missing (const char *binary, const char *debug); -+ - /* From dwarf2read.c */ - - /* Names for a dwarf2 debugging section. The field NORMAL is the normal -diff -Naurp insight-10.0.50.20200110.orig/gdb/testsuite/gdb.base/corefile.exp insight-10.0.50.20200110.new/gdb/testsuite/gdb.base/corefile.exp ---- insight-10.0.50.20200110.orig/gdb/testsuite/gdb.base/corefile.exp 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/testsuite/gdb.base/corefile.exp 2020-02-07 02:55:02.305012549 +0100 -@@ -311,3 +311,33 @@ gdb_test_multiple "core-file $corefile" - pass $test - } - } -+ -+ -+# Test auto-loading of binary files through build-id from the core file. -+set buildid [build_id_debug_filename_get $binfile] -+set wholetest "binfile found by build-id" -+if {$buildid == ""} { -+ untested "$wholetest (binary has no build-id)" -+} else { -+ gdb_exit -+ gdb_start -+ -+ regsub {\.debug$} $buildid {} buildid -+ set debugdir [standard_output_file ${testfile}-debugdir] -+ file delete -force -- $debugdir -+ file mkdir $debugdir/[file dirname $buildid] -+ file copy $binfile $debugdir/$buildid -+ -+ set test "show debug-file-directory" -+ gdb_test_multiple $test $test { -+ -re "The directory where separate debug symbols are searched for is \"(.*)\"\\.\r\n$gdb_prompt $" { -+ set debugdir_orig $expect_out(1,string) -+ pass $test -+ } -+ } -+ gdb_test_no_output "set debug-file-directory $debugdir:$debugdir_orig" "set debug-file-directory" -+ gdb_test "show build-id-core-loads" {Whether CORE-FILE loads the build-id associated files automatically is on\.} -+ gdb_test "core-file $corefile" "\r\nProgram terminated with .*" "core-file without executable" -+ gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*" -+ pass $wholetest -+} -diff -Naurp insight-10.0.50.20200110.orig/gdb/testsuite/gdb.base/new-ui-pending-input.exp insight-10.0.50.20200110.new/gdb/testsuite/gdb.base/new-ui-pending-input.exp ---- insight-10.0.50.20200110.orig/gdb/testsuite/gdb.base/new-ui-pending-input.exp 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/testsuite/gdb.base/new-ui-pending-input.exp 2020-02-07 02:55:02.305012549 +0100 -@@ -62,6 +62,7 @@ proc test_command_line_new_ui_pending_in - set options "" - append options " -iex \"set height 0\"" - append options " -iex \"set width 0\"" -+ append options " -iex \"set build-id-verbose 0\"" - append options " -iex \"new-ui console $extra_tty_name\"" - append options " -ex \"b $bpline\"" - append options " -ex \"run\"" -diff -Naurp insight-10.0.50.20200110.orig/gdb/testsuite/lib/gdb.exp insight-10.0.50.20200110.new/gdb/testsuite/lib/gdb.exp ---- insight-10.0.50.20200110.orig/gdb/testsuite/lib/gdb.exp 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/testsuite/lib/gdb.exp 2020-02-07 02:55:02.306012559 +0100 -@@ -1891,6 +1891,17 @@ proc default_gdb_start { } { - } - } - -+ # Turn off the missing warnings as the testsuite does not expect it. -+ send_gdb "set build-id-verbose 0\n" -+ gdb_expect 10 { -+ -re "$gdb_prompt $" { -+ verbose "Disabled the missing debug infos warnings." 2 -+ } -+ timeout { -+ warning "Could not disable the missing debug infos warnings.." -+ } -+ } -+ - gdb_debug_init - return 0 - } -diff -Naurp insight-10.0.50.20200110.orig/gdb/testsuite/lib/mi-support.exp insight-10.0.50.20200110.new/gdb/testsuite/lib/mi-support.exp ---- insight-10.0.50.20200110.orig/gdb/testsuite/lib/mi-support.exp 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/testsuite/lib/mi-support.exp 2020-02-07 02:55:02.306012559 +0100 -@@ -309,6 +309,16 @@ proc default_mi_gdb_start { args } { - warning "Couldn't set the width to 0." - } - } -+ # Turn off the missing warnings as the testsuite does not expect it. -+ send_gdb "190-gdb-set build-id-verbose 0\n" -+ gdb_expect 10 { -+ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" { -+ verbose "Disabled the missing debug infos warnings." 2 -+ } -+ timeout { -+ warning "Could not disable the missing debug infos warnings.." -+ } -+ } - - if { $separate_inferior_pty } { - mi_create_inferior_pty diff --git a/insight-gdb-archer-pie-addons-keep-disabled.patch b/insight-gdb-archer-pie-addons-keep-disabled.patch deleted file mode 100644 index 16e8790..0000000 --- a/insight-gdb-archer-pie-addons-keep-disabled.patch +++ /dev/null @@ -1,83 +0,0 @@ -diff -Naurp insight-10.0.50.20200110.orig/gdb/breakpoint.c insight-10.0.50.20200110.new/gdb/breakpoint.c ---- insight-10.0.50.20200110.orig/gdb/breakpoint.c 2020-02-07 00:46:03.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/breakpoint.c 2020-02-07 13:55:38.047020009 +0100 -@@ -15397,6 +15397,51 @@ static struct cmd_list_element *enablebr - cmd_list_element *commands_cmd_element = nullptr; - - void -+breakpoints_relocate (struct objfile *objfile, const section_offsets &delta) -+{ -+ struct bp_location *bl, **blp_tmp; -+ int changed = 0; -+ -+ gdb_assert (objfile->separate_debug_objfile_backlink == NULL); -+ -+ ALL_BP_LOCATIONS (bl, blp_tmp) -+ { -+ struct obj_section *osect; -+ -+ /* BL->SECTION can be correctly NULL for breakpoints with multiple -+ locations expanded through symtab. */ -+ -+ ALL_OBJFILE_OSECTIONS (objfile, osect) -+ { -+ CORE_ADDR relocated_address; -+ CORE_ADDR delta_offset; -+ -+ delta_offset = delta[osect->the_bfd_section->index]; -+ if (delta_offset == 0) -+ continue; -+ relocated_address = bl->address + delta_offset; -+ -+ if (obj_section_addr (osect) <= relocated_address -+ && relocated_address < obj_section_endaddr (osect)) -+ { -+ if (bl->inserted) -+ remove_breakpoint (bl); -+ -+ bl->address += delta_offset; -+ bl->requested_address += delta_offset; -+ -+ changed = 1; -+ } -+ } -+ } -+ -+ if (changed) -+ std::sort (bp_locations, bp_locations + bp_locations_count, -+ bp_location_is_less_than); -+} -+ -+void _initialize_breakpoint (void); -+void - _initialize_breakpoint (void) - { - struct cmd_list_element *c; -diff -Naurp insight-10.0.50.20200110.orig/gdb/breakpoint.h insight-10.0.50.20200110.new/gdb/breakpoint.h ---- insight-10.0.50.20200110.orig/gdb/breakpoint.h 2020-01-03 10:42:10.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/breakpoint.h 2020-02-07 13:55:18.987856186 +0100 -@@ -1696,6 +1696,9 @@ extern const char *ep_parse_optional_if_ - UIOUT iff debugging multiple threads. */ - extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout); - -+extern void breakpoints_relocate (struct objfile *objfile, -+ const section_offsets &delta); -+ - /* Print the specified breakpoint. */ - extern void print_breakpoint (breakpoint *bp); - -diff -Naurp insight-10.0.50.20200110.orig/gdb/objfiles.c insight-10.0.50.20200110.new/gdb/objfiles.c ---- insight-10.0.50.20200110.orig/gdb/objfiles.c 2020-01-10 12:05:27.000000000 +0100 -+++ insight-10.0.50.20200110.new/gdb/objfiles.c 2020-02-07 12:57:58.277501554 +0100 -@@ -750,6 +750,11 @@ objfile_relocate1 (struct objfile *objfi - obj_section_addr (s)); - } - -+ /* Final call of breakpoint_re_set can keep breakpoint locations disabled if -+ their addresses match. */ -+ if (objfile->separate_debug_objfile_backlink == NULL) -+ breakpoints_relocate (objfile, delta); -+ - /* Data changed. */ - return 1; - } diff --git a/insight.spec b/insight.spec index 05d5686..fa8ed7c 100644 --- a/insight.spec +++ b/insight.spec @@ -1,6 +1,6 @@ -%global ver 10.0.50 -%global snap 20200110 -%global gnulibsnap 20191216 +%global ver 11.0.50 +%global snap 20201215 +%global gnulibsnap 20200630 # Turn off the brp-python-bytecompile automagic %global _python_bytecompile_extra 0 @@ -18,7 +18,7 @@ Name: insight Version: %(echo %{ver} | tr - .)%{?snap:.%{snap}} -Release: 10%{?dist} +Release: 1%{?dist} Summary: Graphical debugger based on GDB License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain and GFDL Url: https://www.sourceware.org/insight/ @@ -51,7 +51,7 @@ BuildRequires: flex BuildRequires: texinfo-tex BuildRequires: perl-podlators BuildRequires: libbabeltrace-devel -BuildRequires: guile-devel +BuildRequires: guile22-devel # For C++ pretty printers. BuildRequires: libstdc++ @@ -65,52 +65,45 @@ BuildRequires: libipt-devel # Insight patches. -Patch1: insight-7.4.50-relocate.patch -Patch2: insight-10.0-readline-system.patch -Patch3: insight-10.0-fix-a-prototype.patch -Patch4: insight-10.0.50-gcc10.patch -Patch5: insight-10.0.50-python39.patch -Patch6: insight-10.0.50-python39-2.patch +Patch1: insight-11.0.50-relocate.patch # Some patches from gdb. See gdb spec file for info. -Patch101: gdb-vla-intel-fortran-strides.patch -Patch102: gdb-vla-intel-fortran-vla-strings.patch -Patch103: gdb-vla-intel-stringbt-fix.patch -Patch104: gdb-6.3-gstack-20050411.patch -Patch105: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch -Patch106: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch -Patch107: insight-gdb-6.6-buildid-locate.patch -Patch108: gdb-6.6-buildid-locate-solib-missing-ids.patch -Patch109: insight-gdb-6.6-buildid-locate-rpm.patch -Patch110: gdb-bz533176-fortran-omp-step.patch -Patch111: gdb-archer-pie-addons.patch -Patch112: insight-gdb-archer-pie-addons-keep-disabled.patch -Patch113: gdb-moribund-utrace-workaround.patch -Patch114: gdb-6.6-buildid-locate-core-as-arg.patch -Patch115: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch -Patch116: gdb-attach-fail-reasons-5of5.patch -Patch117: gdb-gnat-dwarf-crash-3of3.patch -Patch118: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch -Patch119: gdb-btrobust.patch -Patch120: gdb-jit-reader-multilib.patch -Patch121: gdb-bz1219747-attach-kills.patch -Patch122: gdb-fedora-libncursesw.patch -Patch123: gdb-dts-rhel6-python-compat.patch -Patch124: gdb-6.6-buildid-locate-rpm-scl.patch -Patch125: gdb-6.8-quit-never-aborts.patch -Patch126: gdb-container-rh-pkg.patch -Patch127: gdb-linux_perf-bundle.patch -Patch128: gdb-libexec-add-index.patch -Patch129: gdb-archer.patch -Patch130: gdb-vla-intel-fix-print-char-array.patch +Patch101: insight-11.0-gdb-vla-intel-fortran-vla-strings.patch +Patch102: gdb-vla-intel-stringbt-fix.patch +Patch103: gdb-6.3-gstack-20050411.patch +Patch104: insight-11.0-gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch +Patch105: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch +Patch106: insight-11.0-gdb-6.6-buildid-locate.patch +Patch107: insight-11.0-gdb-6.6-buildid-locate-solib-missing-ids.patch +Patch108: insight-11.0-gdb-6.6-buildid-locate-rpm.patch +Patch109: gdb-bz533176-fortran-omp-step.patch +Patch110: gdb-archer-pie-addons.patch +Patch111: gdb-archer-pie-addons-keep-disabled.patch +Patch112: gdb-moribund-utrace-workaround.patch +Patch113: insight-11.0-gdb-6.6-buildid-locate-core-as-arg.patch +Patch114: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch +Patch115: gdb-attach-fail-reasons-5of5.patch +Patch116: gdb-gnat-dwarf-crash-3of3.patch +Patch117: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch +Patch118: gdb-btrobust.patch +Patch119: gdb-jit-reader-multilib.patch +Patch120: gdb-bz1219747-attach-kills.patch +Patch121: gdb-fedora-libncursesw.patch +Patch122: gdb-dts-rhel6-python-compat.patch +Patch123: gdb-6.6-buildid-locate-rpm-scl.patch +Patch124: gdb-6.8-quit-never-aborts.patch +Patch125: gdb-container-rh-pkg.patch +Patch126: gdb-linux_perf-bundle.patch +Patch127: gdb-libexec-add-index.patch +Patch128: gdb-archer.patch %description Insight is a tight graphical user interface to GDB written in Tcl/Tk. It provides a comprehensive interface that enables users to harness most of GDB's power. It's also probably the only up-to-date UI for -GDB version 8.x. +the latest GDB version. #------------------------------------------------------------------------------- @@ -120,11 +113,6 @@ GDB version 8.x. %setup -q -n insight-%{version} %patch1 -p1 -b .relocate -%patch2 -p1 -b .readline-system -%patch3 -p1 -b .fix-a-prototype -%patch4 -p1 -b .gcc10 -%patch5 -p1 -b .python39 -%patch6 -p1 -b .python39-2 %patch101 -p1 %patch102 -p1 @@ -154,8 +142,6 @@ GDB version 8.x. %patch126 -p1 %patch127 -p1 %patch128 -p1 -%patch129 -p1 -%patch130 -p1 #------------------------------------------------------------------------------- @@ -163,14 +149,13 @@ GDB version 8.x. #------------------------------------------------------------------------------- TOPDIR=`pwd` -rm -rf readline # Need a complete reconfiguration after unbundling. autogen Makefile.def autoreconf -# Patch requires some autotools rebuilds. +# Patches require some autotools rebuilds. for location in gdb/gdbtk/plugins libgui do ( @@ -181,13 +166,8 @@ do ( ) done -# Patch "readline-system" requires autoconf - -( - cd gdb - aclocal -I "${TOPDIR}/config" - autoconf -) +# Force documentation reconfiguration. +touch gdb/doc/version.subst # Get inclusion paths. @@ -360,6 +340,13 @@ ${INSTALL} -m 644 gdb/gdbtk/insight_icon.svg \ %changelog #------------------------------------------------------------------------------- +* Sat Dec 5 2020 Patrick Monnerat 11.0.50.20201215-1 +- New upstream snapshot. +- Fixes FTBFS. + https://bugzilla.redhat.com/show_bug.cgi?id=1906699 +- Uses guile 2.2 + https://bugzilla.redhat.com/show_bug.cgi?id=1901360 + * Sat Aug 8 2020 Patrick Monnerat 10.0.50.20200210-10 - Patch "python39-2" removes another Python 3.9 deprecated function call. diff --git a/sources b/sources index e7cc1ef..e78df78 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (insight-10.0.50.20200110.tar.xz) = 3b4b9051c1dcd2a03ae533099bd1da5e367e62058ae4fa640101ef13acf5997d52baa43f93de41fef85cac9a952a1501392f0c850876d0539e02ded0d26e86cc +SHA512 (insight-11.0.50.20201215.tar.xz) = 1d6012161de665aedfafadeaa3118aee1ea020c6fe9afac000b4db5045eaacafd6b8a12f08ec991dc3553777efc140ce28d629f63ca9fcf11e8e5451f8927c7b