diff --git a/gdb-7.10-swo18929.patch b/gdb-7.10-swo18929.patch deleted file mode 100644 index 55d1f44..0000000 --- a/gdb-7.10-swo18929.patch +++ /dev/null @@ -1,37 +0,0 @@ -https://sourceware.org/bugzilla/show_bug.cgi?id=18929 - ---- - gdb/cp-valprint.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -Index: gdb-7.11/gdb/cp-valprint.c -=================================================================== ---- gdb-7.11.orig/gdb/cp-valprint.c 2016-03-21 10:04:07.845131361 +0100 -+++ gdb-7.11/gdb/cp-valprint.c 2016-03-21 10:04:49.089597879 +0100 -@@ -313,11 +313,13 @@ cp_print_value_fields (struct type *type - } - else if (field_is_static (&TYPE_FIELD (type, i))) - { -- struct value *v = NULL; -- - TRY - { -+ struct value *v = NULL; - v = value_static_field (type, i); -+ cp_print_static_field (TYPE_FIELD_TYPE (type, i), -+ v, stream, recurse + 1, -+ options); - } - - CATCH (ex, RETURN_MASK_ERROR) -@@ -327,10 +329,6 @@ cp_print_value_fields (struct type *type - ex.message); - } - END_CATCH -- -- cp_print_static_field (TYPE_FIELD_TYPE (type, i), -- v, stream, recurse + 1, -- options); - } - else if (i == vptr_fieldno && type == vptr_basetype) - { diff --git a/gdb-8.3.1.tar.bz2 b/gdb-8.3.1.tar.bz2 new file mode 100644 index 0000000..a37b156 --- /dev/null +++ b/gdb-8.3.1.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05c64ab7298487fde1aac402026ef0569cf7e703054d2a42e272292a0b096fdf +size 29382553 diff --git a/gdb-8.3.tar.bz2 b/gdb-8.3.tar.bz2 deleted file mode 100644 index 20e6abe..0000000 --- a/gdb-8.3.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e722dd64f86742c5be2da15dea9f8906f44f20dd89f7f98bcad93767ffaf7638 -size 29368870 diff --git a/gdb-fix-breakpoints-on-file-reloads-for-pie-binaries.patch b/gdb-fix-breakpoints-on-file-reloads-for-pie-binaries.patch deleted file mode 100644 index 31988a0..0000000 --- a/gdb-fix-breakpoints-on-file-reloads-for-pie-binaries.patch +++ /dev/null @@ -1,154 +0,0 @@ -Fix breakpoints on file reloads for PIE binaries - -When a binary is built using PIE, reloading the file will cause GDB to error -on restart. For example: -gdb ./a.out -(gdb) break main -(gdb) run -(gdb) file ./a.out -(gdb) continue - -Will cause GDB to error with: -Continuing. -Warning: -Cannot insert breakpoint 1. -Cannot access memory at address 0x9e0 -Command aborted. - -This is due to the symbol offsets not being relocated after reloading the file. - -Fix is to ensure solib_create_inferior_hook is called, in the same manner as -infrun.c:follow_exec(). - -Expand the idempotent test to cover PIE scenarios. - -gdb/ChangeLog: - - * symfile.c (symbol_file_command): Call solib_create_inferior_hook. - -gdb/testsuite/ChangeLog: - - * gdb.base/break-idempotent.exp: Test both PIE and non PIE. - ---- - gdb/ChangeLog | 4 ++ - gdb/symfile.c | 12 ++++++ - gdb/testsuite/ChangeLog | 4 ++ - gdb/testsuite/gdb.base/break-idempotent.exp | 66 ++++++++++++++++------------- - 4 files changed, 56 insertions(+), 30 deletions(-) - -diff --git a/gdb/symfile.c b/gdb/symfile.c -index bd79315687..a03ac29541 100644 ---- a/gdb/symfile.c -+++ b/gdb/symfile.c -@@ -1672,7 +1672,19 @@ symbol_file_command (const char *args, int from_tty) - - validate_readnow_readnever (flags); - -+ /* Set SYMFILE_DEFER_BP_RESET because the proper displacement for a PIE -+ (Position Independent Executable) main symbol file will only be -+ computed by the solib_create_inferior_hook below. Without it, -+ breakpoint_re_set would fail to insert the breakpoints with the zero -+ displacement. */ -+ add_flags |= SYMFILE_DEFER_BP_RESET; -+ - symbol_file_add_main_1 (name, add_flags, flags, offset); -+ -+ solib_create_inferior_hook (from_tty); -+ -+ /* Now it's safe to re-add the breakpoints. */ -+ breakpoint_re_set (); - } - } - -diff --git a/gdb/testsuite/gdb.base/break-idempotent.exp b/gdb/testsuite/gdb.base/break-idempotent.exp -index 902a5f818b..96f91c50f9 100644 ---- a/gdb/testsuite/gdb.base/break-idempotent.exp -+++ b/gdb/testsuite/gdb.base/break-idempotent.exp -@@ -36,23 +36,6 @@ - - standard_testfile - --if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { -- return -1 --} -- --if ![runto_main] then { -- fail "can't run to main" -- return 0 --} -- --if [is_remote host] { -- set arg [remote_download host $binfile] -- if { $arg == "" } { -- perror "download failed" -- return -1 -- } --} -- - # Force a breakpoint re-set in GDB. Currently this is done by - # reloading symbols with the "file" command. - -@@ -123,7 +106,7 @@ proc set_breakpoint { break_command } { - proc test_break { always_inserted break_command } { - set cmd [lindex [split "$break_command"] 0] - -- with_test_prefix "always-inserted $always_inserted: $cmd" { -+ with_test_prefix "$cmd" { - delete_breakpoints - - if ![runto_main] then { -@@ -163,20 +146,43 @@ proc test_break { always_inserted break_command } { - } - } - --foreach always_inserted { "off" "on" } { -- test_break $always_inserted "break" -+# The testcase uses the "file" command to force breakpoint re-set in -+# GDB. Test both with and without PIE, as GDB used to mishandle -+# breakpoint re-set when reloading PIEs. -+foreach_with_prefix pie { "nopie" "pie" } { -+ -+ set opts {debug} -+ lappend opts $pie - -- if {![skip_hw_breakpoint_tests]} { -- test_break $always_inserted "hbreak" -+ set binfile [standard_output_file $testfile-$pie] -+ -+ if {[prepare_for_testing "failed to prepare" $binfile $srcfile $opts]} { -+ continue - } - -- if {![skip_hw_watchpoint_tests]} { -- test_break $always_inserted "watch" -+ if [is_remote host] { -+ set arg [remote_download host $binfile] -+ if { $arg == "" } { -+ untested "download failed" -+ continue -+ } - } - -- if {![skip_hw_watchpoint_access_tests] -- && ![skip_hw_watchpoint_multi_tests]} { -- test_break $always_inserted "rwatch" -- test_break $always_inserted "awatch" -+ foreach_with_prefix always_inserted { "off" "on" } { -+ test_break $always_inserted "break" -+ -+ if {![skip_hw_breakpoint_tests]} { -+ test_break $always_inserted "hbreak" -+ } -+ -+ if {![skip_hw_watchpoint_tests]} { -+ test_break $always_inserted "watch" -+ } -+ -+ if {![skip_hw_watchpoint_access_tests] -+ && ![skip_hw_watchpoint_multi_tests]} { -+ test_break $always_inserted "rwatch" -+ test_break $always_inserted "awatch" -+ } - } - } diff --git a/gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch b/gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch deleted file mode 100644 index 3e2cdf2..0000000 --- a/gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch +++ /dev/null @@ -1,431 +0,0 @@ -commit b73715df01e6e9b3de5a49cd7bf4170deef48461 -Author: Tom de Vries -Date: Thu Apr 18 17:05:43 2019 +0100 - - [gdb] Handle vfork in thread with follow-fork-mode child - - When debugging any of the testcases added by this commit, which do a - vfork in a thread with "set follow-fork-mode child" + "set - detach-on-fork on", we run into this assertion: - - ... - src/gdb/nat/x86-linux-dregs.c:146: internal-error: \ - void x86_linux_update_debug_registers(lwp_info*): \ - Assertion `lwp_is_stopped (lwp)' failed. - ... - - The assert is caused by the following: the vfork-child exit or exec - event is handled by handle_vfork_child_exec_or_exit, which calls - target_detach to detach from the vfork parent. During target_detach - we call linux_nat_target::detach, which: - - #1 - stops all the threads - #2 - waits for all the threads to be stopped - #3 - detaches all the threads - - However, during the second step we run into this code in - stop_wait_callback: - - ... - /* If this is a vfork parent, bail out, it is not going to report - any SIGSTOP until the vfork is done with. */ - if (inf->vfork_child != NULL) - return 0; - ... - - and we don't wait for the threads to be stopped, which results in this - assert in x86_linux_update_debug_registers triggering during the third - step: - - ... - gdb_assert (lwp_is_stopped (lwp)); - ... - - The fix is to reset the vfork parent's vfork_child field before - calling target_detach in handle_vfork_child_exec_or_exit. There's - already similar code for the other paths handled by - handle_vfork_child_exec_or_exit, so this commit refactors the code a - bit so that all paths share the same code. - - The new tests cover both a vfork child exiting, and a vfork child - execing, since both cases would trigger the assertion. - - The new testcases also exercise following the vfork children with "set - detach-on-fork off", since it doesn't seem to be tested anywhere. - - Tested on x86_64-linux, using native and native-gdbserver. - - gdb/ChangeLog: - 2019-04-18 Tom de Vries - Pedro Alves - - PR gdb/24454 - * infrun.c (handle_vfork_child_exec_or_exit): Reset vfork parent's - vfork_child field before calling target_detach. - - gdb/testsuite/ChangeLog: - 2019-04-18 Tom de Vries - Pedro Alves - - PR gdb/24454 - * gdb.threads/vfork-follow-child-exec.c: New file. - * gdb.threads/vfork-follow-child-exec.exp: New file. - * gdb.threads/vfork-follow-child-exit.c: New file. - * gdb.threads/vfork-follow-child-exit.exp: New file. - -diff --git a/gdb/infrun.c b/gdb/infrun.c -index 37713b24fe..37df561de0 100644 ---- a/gdb/infrun.c -+++ b/gdb/infrun.c -@@ -915,10 +915,14 @@ handle_vfork_child_exec_or_exit (int exec) - int resume_parent = -1; - - /* This exec or exit marks the end of the shared memory region -- between the parent and the child. If the user wanted to -- detach from the parent, now is the time. */ -+ between the parent and the child. Break the bonds. */ -+ inferior *vfork_parent = inf->vfork_parent; -+ inf->vfork_parent->vfork_child = NULL; -+ inf->vfork_parent = NULL; - -- if (inf->vfork_parent->pending_detach) -+ /* If the user wanted to detach from the parent, now is the -+ time. */ -+ if (vfork_parent->pending_detach) - { - struct thread_info *tp; - struct program_space *pspace; -@@ -926,7 +930,7 @@ handle_vfork_child_exec_or_exit (int exec) - - /* follow-fork child, detach-on-fork on. */ - -- inf->vfork_parent->pending_detach = 0; -+ vfork_parent->pending_detach = 0; - - gdb::optional - maybe_restore_inferior; -@@ -941,7 +945,7 @@ handle_vfork_child_exec_or_exit (int exec) - maybe_restore_thread.emplace (); - - /* We're letting loose of the parent. */ -- tp = any_live_thread_of_inferior (inf->vfork_parent); -+ tp = any_live_thread_of_inferior (vfork_parent); - switch_to_thread (tp); - - /* We're about to detach from the parent, which implicitly -@@ -964,7 +968,7 @@ handle_vfork_child_exec_or_exit (int exec) - if (print_inferior_events) - { - const char *pidstr -- = target_pid_to_str (ptid_t (inf->vfork_parent->pid)); -+ = target_pid_to_str (ptid_t (vfork_parent->pid)); - - target_terminal::ours_for_output (); - -@@ -982,7 +986,7 @@ handle_vfork_child_exec_or_exit (int exec) - } - } - -- target_detach (inf->vfork_parent, 0); -+ target_detach (vfork_parent, 0); - - /* Put it back. */ - inf->pspace = pspace; -@@ -997,10 +1001,7 @@ handle_vfork_child_exec_or_exit (int exec) - inf->removable = 1; - set_current_program_space (inf->pspace); - -- resume_parent = inf->vfork_parent->pid; -- -- /* Break the bonds. */ -- inf->vfork_parent->vfork_child = NULL; -+ resume_parent = vfork_parent->pid; - } - else - { -@@ -1030,17 +1031,13 @@ handle_vfork_child_exec_or_exit (int exec) - set_current_program_space (pspace); - inf->removable = 1; - inf->symfile_flags = SYMFILE_NO_READ; -- clone_program_space (pspace, inf->vfork_parent->pspace); -+ clone_program_space (pspace, vfork_parent->pspace); - inf->pspace = pspace; - inf->aspace = pspace->aspace; - -- resume_parent = inf->vfork_parent->pid; -- /* Break the bonds. */ -- inf->vfork_parent->vfork_child = NULL; -+ resume_parent = vfork_parent->pid; - } - -- inf->vfork_parent = NULL; -- - gdb_assert (current_program_space == inf->pspace); - - if (non_stop && resume_parent != -1) -diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exec.c b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.c -new file mode 100644 -index 0000000000..80632d1772 ---- /dev/null -+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.c -@@ -0,0 +1,66 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2019 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+static char *program_name; -+ -+static void * -+f (void *arg) -+{ -+ int res = vfork (); -+ -+ if (res == -1) -+ { -+ perror ("vfork"); -+ return NULL; -+ } -+ else if (res == 0) -+ { -+ /* Child. */ -+ execl (program_name, program_name, "1", NULL); -+ perror ("exec"); -+ abort (); -+ } -+ else -+ { -+ /* Parent. */ -+ return NULL; -+ } -+} -+ -+int -+main (int argc, char **argv) -+{ -+ pthread_t tid; -+ -+ if (argc > 1) -+ { -+ /* Getting here via execl. */ -+ return 0; -+ } -+ -+ program_name = argv[0]; -+ -+ pthread_create (&tid, NULL, f, NULL); -+ pthread_join (tid, NULL); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp -new file mode 100644 -index 0000000000..5a28715fa0 ---- /dev/null -+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp -@@ -0,0 +1,64 @@ -+# Copyright (C) 2019 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . */ -+ -+# Test following a vfork child that execs, when the vfork parent is a -+# threaded program, and it's a non-main thread that vforks. -+ -+standard_testfile -+ -+if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} { -+ return -1 -+} -+ -+# DETACH indicates whether "set detach-on-fork" is enabled. It is -+# either "on" or "off". -+ -+proc test_vfork {detach} { -+ global binfile -+ -+ clean_restart $binfile -+ -+ if ![runto_main] then { -+ fail "can't run to main" -+ return 0 -+ } -+ -+ delete_breakpoints -+ -+ gdb_test_no_output "set follow-fork-mode child" -+ gdb_test_no_output "set detach-on-fork $detach" -+ -+ if {$detach == "off"} { -+ gdb_test "continue" \ -+ [multi_line \ -+ "Attaching after .* vfork to child .*" \ -+ ".*New inferior 2 .*" \ -+ ".* is executing new program: .*" \ -+ ".*Inferior 2 .* exited normally.*"] -+ } else { -+ gdb_test "continue" \ -+ [multi_line \ -+ "Attaching after .* vfork to child .*" \ -+ ".*New inferior 2 .*" \ -+ ".*Detaching vfork parent process .* after child exec.*" \ -+ ".*Inferior 1 .* detached.*" \ -+ ".*is executing new program: .*" \ -+ ".*Inferior 2 .*exited normally.*"] -+ } -+} -+ -+foreach_with_prefix detach-on-fork {"off" "on"} { -+ test_vfork ${detach-on-fork} -+} -diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exit.c b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.c -new file mode 100644 -index 0000000000..6ae254cce9 ---- /dev/null -+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.c -@@ -0,0 +1,52 @@ -+/* This testcase is part of GDB, the GNU debugger. -+ -+ Copyright 2019 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+#include -+#include -+ -+static void * -+f (void *arg) -+{ -+ int res = vfork (); -+ -+ if (res == -1) -+ { -+ perror ("vfork"); -+ return NULL; -+ } -+ else if (res == 0) -+ { -+ /* Child. */ -+ _exit (0); -+ } -+ else -+ { -+ /* Parent. */ -+ return NULL; -+ } -+} -+ -+int -+main (void) -+{ -+ pthread_t tid; -+ -+ pthread_create (&tid, NULL, f, NULL); -+ pthread_join (tid, NULL); -+ return 0; -+} -diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp -new file mode 100644 -index 0000000000..f07215d41c ---- /dev/null -+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp -@@ -0,0 +1,60 @@ -+# Copyright (C) 2019 Free Software Foundation, Inc. -+ -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . */ -+ -+# Test following a vfork child that exits, when the vfork parent is a -+# threaded program, and it's a non-main thread that vforks. -+ -+standard_testfile -+ -+if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} { -+ return -1 -+} -+ -+# DETACH indicates whether "set detach-on-fork" is enabled. It is -+# either "on" or "off". -+ -+proc test_vfork {detach} { -+ global binfile -+ -+ clean_restart $binfile -+ -+ if ![runto_main] then { -+ fail "can't run to main" -+ return 0 -+ } -+ -+ gdb_test_no_output "set follow-fork-mode child" -+ gdb_test_no_output "set detach-on-fork $detach" -+ -+ if {$detach == "off"} { -+ gdb_test "continue" \ -+ [multi_line \ -+ "Attaching after .* vfork to child .*" \ -+ ".*New inferior 2 .*" \ -+ ".*Inferior 2 .*exited normally.*"] -+ } else { -+ gdb_test "continue" \ -+ [multi_line \ -+ "Attaching after .* vfork to child .*" \ -+ ".*New inferior 2 .*" \ -+ ".*Detaching vfork parent process .* after child exit.*" \ -+ ".*Inferior 1 .* detached.*" \ -+ ".*Inferior 2 .*exited normally.*"] -+ } -+} -+ -+foreach_with_prefix detach-on-fork {"off" "on"} { -+ test_vfork ${detach-on-fork} -+} diff --git a/gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.patch b/gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.patch new file mode 100644 index 0000000..7c8c31e --- /dev/null +++ b/gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.patch @@ -0,0 +1,84 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Tue, 2 Jul 2019 15:58:29 +0100 +Subject: gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.patch + +;; Fix 'gdb: warning: Loadable section ".note.gnu.property" outside of +;; ELF segments' (Nick Clifton, RH BZ 1553086). +;; This is a binutils patch. + +Stop the BFD library from issuing a warning message when processing allocated sections in debuginfo files that lie outside of any loadable segment. + + PR 24717 + * elf.c (is_debuginfo_file): New function. + (assign_file_positions_for_non_load_sections): Do not warn about + allocated sections outside of loadable segments if they are found + in a debuginfo file. + * elf-bfd.h (is_debuginfo_file): Prototype. + +diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h +--- a/bfd/elf-bfd.h ++++ b/bfd/elf-bfd.h +@@ -2751,6 +2751,8 @@ extern bfd_vma elf64_r_sym (bfd_vma); + extern bfd_vma elf32_r_info (bfd_vma, bfd_vma); + extern bfd_vma elf32_r_sym (bfd_vma); + ++extern bfd_boolean is_debuginfo_file (bfd *); ++ + /* Large common section. */ + extern asection _bfd_elf_large_com_section; + +diff --git a/bfd/elf.c b/bfd/elf.c +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -5800,6 +5800,35 @@ assign_file_positions_for_load_sections (bfd *abfd, + return TRUE; + } + ++/* Determine if a bfd is a debuginfo file. Unfortunately there ++ is no defined method for detecting such files, so we have to ++ use heuristics instead. */ ++ ++bfd_boolean ++is_debuginfo_file (bfd *abfd) ++{ ++ if (abfd == NULL || bfd_get_flavour (abfd) != bfd_target_elf_flavour) ++ return FALSE; ++ ++ Elf_Internal_Shdr **start_headers = elf_elfsections (abfd); ++ Elf_Internal_Shdr **end_headers = start_headers + elf_numsections (abfd); ++ Elf_Internal_Shdr **headerp; ++ ++ for (headerp = start_headers; headerp < end_headers; headerp ++) ++ { ++ Elf_Internal_Shdr *header = * headerp; ++ ++ /* Debuginfo files do not have any allocated SHT_PROGBITS sections. ++ The only allocated sections are SHT_NOBITS or SHT_NOTES. */ ++ if ((header->sh_flags & SHF_ALLOC) == SHF_ALLOC ++ && header->sh_type != SHT_NOBITS ++ && header->sh_type != SHT_NOTE) ++ return FALSE; ++ } ++ ++ return TRUE; ++} ++ + /* Assign file positions for the other sections. */ + + static bfd_boolean +@@ -5833,7 +5862,13 @@ assign_file_positions_for_non_load_sections (bfd *abfd, + BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos); + else if ((hdr->sh_flags & SHF_ALLOC) != 0) + { +- if (hdr->sh_size != 0) ++ if (hdr->sh_size != 0 ++ /* PR 24717 - debuginfo files are known to be not strictly ++ compliant with the ELF standard. In particular they often ++ have .note.gnu.property sections that are outside of any ++ loadable segment. This is not a problem for such files, ++ so do not warn about them. */ ++ && ! is_debuginfo_file (abfd)) + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB: warning: allocated section `%s' not in segment"), diff --git a/gdb-rhbz1704406-disable-style-log-output-1of3.patch b/gdb-rhbz1704406-disable-style-log-output-1of3.patch new file mode 100644 index 0000000..2afde91 --- /dev/null +++ b/gdb-rhbz1704406-disable-style-log-output-1of3.patch @@ -0,0 +1,88 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Tom Tromey +Date: Tue, 14 May 2019 08:04:22 -0600 +Subject: gdb-rhbz1704406-disable-style-log-output-1of3.patch + +;; Fix 'Color control codes should not appear in logging output' +;; Tom Tromey, RH BZ 1704406 + +Add "style" proc to the test suite + +This adds a "style" helper proc to the test suite, and updates +existing style tests to use it. Thanks to Sergio for the idea. + +Tested on x86-64 Fedora 29. + +gdb/testsuite/ChangeLog +2019-05-22 Tom Tromey + + * gdb.base/info-shared.exp (check_info_shared): Use "style". + * gdb.base/style.exp: Use "style". + * lib/gdb-utils.exp (style): New proc. + +diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp +--- a/gdb/testsuite/gdb.base/style.exp ++++ b/gdb/testsuite/gdb.base/style.exp +@@ -41,10 +41,10 @@ save_vars { env(TERM) } { + + gdb_test_no_output "set style enabled on" + +- set main_expr "\033\\\[33mmain\033\\\[m" +- set base_file_expr "\033\\\[32m.*style\\.c\033\\\[m" ++ set main_expr [style main function] ++ set base_file_expr [style ".*style\\.c" file] + set file_expr "$base_file_expr:\[0-9\]" +- set arg_expr "\033\\\[36marg.\033\\\[m" ++ set arg_expr [style "arg." variable] + + gdb_test "frame" \ + "$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*" +@@ -58,7 +58,7 @@ save_vars { env(TERM) } { + + gdb_test "break main" "file $base_file_expr.*" + +- gdb_test "print &main" " = .* \033\\\[34m$hex\033\\\[m <$main_expr>" ++ gdb_test "print &main" " = .* [style $hex address] <$main_expr>" + + # Regression test for a bug where line-wrapping would occur at the + # wrong spot with styling. There were different bugs at different +@@ -86,11 +86,12 @@ save_vars { env(TERM) } { + gdb_exit + gdb_spawn + +- gdb_test "" "\033\\\[35;1mGNU gdb.*\033\\\[m.*" \ ++ set vers [style "GNU gdb.*" "35;1"] ++ gdb_test "" "${vers}.*" \ + "version is styled" + + set quoted [string_to_regexp $binfile] + gdb_test "file $binfile" \ +- "Reading symbols from \033\\\[32m${quoted}\033\\\[m..." \ ++ "Reading symbols from [style $quoted file]..." \ + "filename is styled when loading symbol file" + } +diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp +--- a/gdb/testsuite/lib/gdb-utils.exp ++++ b/gdb/testsuite/lib/gdb-utils.exp +@@ -37,3 +37,21 @@ proc string_to_regexp {str} { + regsub -all {[]*+.|(){}^$\[\\]} $str {\\&} result + return $result + } ++ ++# Wrap STR in an ANSI terminal escape sequences -- one to set the ++# style to STYLE, and one to reset the style to the default. The ++# return value is suitable for use as a regular expression. ++ ++# STYLE can either be the payload part of an ANSI terminal sequence, ++# or a shorthand for one of the gdb standard styles: "file", ++# "function", "variable", or "address". ++ ++proc style {str style} { ++ switch -exact -- $style { ++ file { set style 32 } ++ function { set style 33 } ++ variable { set style 36 } ++ address { set style 34 } ++ } ++ return "\033\\\[${style}m${str}\033\\\[m" ++} diff --git a/gdb-rhbz1704406-disable-style-log-output-2of3.patch b/gdb-rhbz1704406-disable-style-log-output-2of3.patch new file mode 100644 index 0000000..aac03c9 --- /dev/null +++ b/gdb-rhbz1704406-disable-style-log-output-2of3.patch @@ -0,0 +1,194 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Tom Tromey +Date: Tue, 30 Apr 2019 11:17:15 -0600 +Subject: gdb-rhbz1704406-disable-style-log-output-2of3.patch + +;; Fix 'Color control codes should not appear in logging output' +;; Tom Tromey, RH BZ 1704406 + +Do not emit style escape sequences to log file + +PR gdb/24502 requests that the "set logging" log file not contain +style escape sequences emitted by gdb. + +This seemed like a reasonable request to me, so this patch implements +filtering for the log file. + +This also updates a comment in ui-style.h that I noticed while writing +the patch. + +Tested on x86-64 Fedora 29. + +gdb/ChangeLog +2019-06-14 Tom Tromey + + PR gdb/24502: + * ui-style.h (skip_ansi_escape): Update comment. + * ui-file.h (class no_terminal_escape_file): New class. + * ui-file.c (no_terminal_escape_file::write) + (no_terminal_escape_file::puts): New methods. + * cli/cli-logging.c (handle_redirections): Use + no_terminal_escape_file. + +gdb/testsuite/ChangeLog +2019-06-14 Tom Tromey + + PR gdb/24502: + * gdb.base/style-logging.exp: New file. + +diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c +--- a/gdb/cli/cli-logging.c ++++ b/gdb/cli/cli-logging.c +@@ -117,7 +117,7 @@ handle_redirections (int from_tty) + return; + } + +- stdio_file_up log (new stdio_file ()); ++ stdio_file_up log (new no_terminal_escape_file ()); + if (!log->open (logging_filename, logging_overwrite ? "w" : "a")) + perror_with_name (_("set logging")); + +diff --git a/gdb/testsuite/gdb.base/style-logging.exp b/gdb/testsuite/gdb.base/style-logging.exp +new file mode 100644 +--- /dev/null ++++ b/gdb/testsuite/gdb.base/style-logging.exp +@@ -0,0 +1,64 @@ ++# Copyright 2019 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Test that logging does not style. ++ ++if {[is_remote host]} { ++ untested "does not work on remote host" ++ return 0 ++} ++ ++standard_testfile style.c ++ ++save_vars { env(TERM) } { ++ # We need an ANSI-capable terminal to get the output. ++ setenv TERM ansi ++ ++ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { ++ return -1 ++ } ++ ++ if {![runto_main]} { ++ fail "style tests failed" ++ return ++ } ++ ++ gdb_test_no_output "set style enabled on" ++ ++ set log_name [standard_output_file log.txt] ++ gdb_test_no_output "set logging file $log_name" ++ gdb_test_no_output "set logging overwrite on" ++ gdb_test "set logging on" "Copying output to .*" ++ ++ set main_expr [style main function] ++ set base_file_expr [style ".*style\\.c" file] ++ set file_expr "$base_file_expr:\[0-9\]" ++ set arg_expr [style "arg." variable] ++ gdb_test "frame" \ ++ "$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*" ++ ++ gdb_test "set logging off" "Done logging to .*" ++ ++ set fd [open $log_name] ++ set data [read -nonewline $fd] ++ close $fd ++ ++ set testname "log is escape-free" ++ if {[regexp "\033" $data]} { ++ fail $testname ++ } else { ++ pass $testname ++ } ++} +diff --git a/gdb/ui-file.c b/gdb/ui-file.c +--- a/gdb/ui-file.c ++++ b/gdb/ui-file.c +@@ -332,3 +332,33 @@ tee_file::isatty () + { + return m_one->isatty (); + } ++ ++void ++no_terminal_escape_file::write (const char *buf, long length_buf) ++{ ++ std::string copy (buf, length_buf); ++ this->puts (copy.c_str ()); ++} ++ ++/* See ui-file.h. */ ++ ++void ++no_terminal_escape_file::puts (const char *buf) ++{ ++ while (*buf != '\0') ++ { ++ const char *esc = strchr (buf, '\033'); ++ if (esc == nullptr) ++ break; ++ ++ int n_read = 0; ++ if (!skip_ansi_escape (esc, &n_read)) ++ ++esc; ++ ++ this->stdio_file::write (buf, esc - buf); ++ buf = esc + n_read; ++ } ++ ++ if (*buf != '\0') ++ this->stdio_file::write (buf, strlen (buf)); ++} +diff --git a/gdb/ui-file.h b/gdb/ui-file.h +--- a/gdb/ui-file.h ++++ b/gdb/ui-file.h +@@ -264,4 +264,20 @@ private: + bool m_close_one, m_close_two; + }; + ++/* A ui_file implementation that filters out terminal escape ++ sequences. */ ++ ++class no_terminal_escape_file : public stdio_file ++{ ++public: ++ no_terminal_escape_file () ++ { ++ } ++ ++ /* Like the stdio_file methods, but these filter out terminal escape ++ sequences. */ ++ void write (const char *buf, long length_buf) override; ++ void puts (const char *linebuffer) override; ++}; ++ + #endif +diff --git a/gdb/ui-style.h b/gdb/ui-style.h +--- a/gdb/ui-style.h ++++ b/gdb/ui-style.h +@@ -233,8 +233,8 @@ private: + + /* Skip an ANSI escape sequence in BUF. BUF must begin with an ESC + character. Return true if an escape sequence was successfully +- skipped; false otherwise. In either case, N_READ is updated to +- reflect the number of chars read from BUF. */ ++ skipped; false otherwise. If an escape sequence was skipped, ++ N_READ is updated to reflect the number of chars read from BUF. */ + + extern bool skip_ansi_escape (const char *buf, int *n_read); + diff --git a/gdb-rhbz1704406-disable-style-log-output-3of3.patch b/gdb-rhbz1704406-disable-style-log-output-3of3.patch new file mode 100644 index 0000000..9ffd67d --- /dev/null +++ b/gdb-rhbz1704406-disable-style-log-output-3of3.patch @@ -0,0 +1,30 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Andrew Burgess +Date: Fri, 14 Jun 2019 23:31:10 +0100 +Subject: gdb-rhbz1704406-disable-style-log-output-3of3.patch + +;; Fix 'Color control codes should not appear in logging output' +;; Tom Tromey, RH BZ 1704406 + +gdb: Remove file path from test name + +Having paths in test names makes comparing sum files difficult, rename +a test to avoid paths in test names. + +gdb/testsuite/ChangeLog: + + * gdb.base/style-logging.exp: Remove path from test name. + +diff --git a/gdb/testsuite/gdb.base/style-logging.exp b/gdb/testsuite/gdb.base/style-logging.exp +--- a/gdb/testsuite/gdb.base/style-logging.exp ++++ b/gdb/testsuite/gdb.base/style-logging.exp +@@ -38,7 +38,8 @@ save_vars { env(TERM) } { + gdb_test_no_output "set style enabled on" + + set log_name [standard_output_file log.txt] +- gdb_test_no_output "set logging file $log_name" ++ gdb_test_no_output "set logging file $log_name" \ ++ "set logging filename" + gdb_test_no_output "set logging overwrite on" + gdb_test "set logging on" "Copying output to .*" + diff --git a/gdb-rhbz1708192-parse_macro_definition-crash.patch b/gdb-rhbz1708192-parse_macro_definition-crash.patch new file mode 100644 index 0000000..84d5f92 --- /dev/null +++ b/gdb-rhbz1708192-parse_macro_definition-crash.patch @@ -0,0 +1,69 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Fri, 10 May 2019 16:57:26 -0400 +Subject: gdb-rhbz1708192-parse_macro_definition-crash.patch + +;; "Fix" segfault that happens on parse_macro_definition because +;; debugedit corrupts the .debug_macro section. +;; Sergio Durigan Junior, RH BZ 1708192. + +Don't crash if dwarf_decode_macro_bytes's 'body' is NULL + +Hi, + +Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192 + https://bugzilla.redhat.com/show_bug.cgi?id=1708786 + +During the Fedora RPM build process, gdb-add-index is invoked to +extract the DWARF index from the binary, and GDB will segfault because +dwarf2read.c:parse_definition_macro's 'body' variable is NULL. + +The underlying problem is that Fedora's rpm-build's "debugedit" +program will silently corrupt .debug_macro strings when a binary is +compiled with -g3. This is being taken care of by Mark Wielaard, +here: + + https://bugzilla.redhat.com/show_bug.cgi?id=1708786 + +However, I still feel it's important to make GDB more resilient +against invalid DWARF input, so I'm proposing this rather simple patch +to catch the situation when "body == NULL" (i.e., it's probably been +corrupted) and issue a complaint. This is not a real fix to the +problem, of course, but at least GDB is able to finish without +segfaulting. + +OK for master? + +gdb/ChangeLog: +2019-05-15 Sergio Durigan Junior + + Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192 + * dwarf2read.c (dwarf_decode_macro_bytes): Check whether 'body' is + NULL, and complain if that's the case. + +diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c +--- a/gdb/dwarf2read.c ++++ b/gdb/dwarf2read.c +@@ -24627,7 +24627,21 @@ dwarf_decode_macro_bytes (struct dwarf2_cu *cu, + is_define ? _("definition") : _("undefinition"), + line == 0 ? _("zero") : _("non-zero"), line, body); + +- if (is_define) ++ if (body == NULL) ++ { ++ /* Fedora's rpm-build's "debugedit" binary ++ corrupted .debug_macro sections. ++ ++ For more info, see ++ https://bugzilla.redhat.com/show_bug.cgi?id=1708786 */ ++ complaint (_("debug info gives %s invalid macro %s " ++ "without body (corrupted?) at line %d " ++ "on file %s"), ++ at_commandline ? _("command-line") : _("in-file"), ++ is_define ? _("definition") : _("undefinition"), ++ line, current_file->filename); ++ } ++ else if (is_define) + parse_macro_definition (current_file, line, body); + else + { diff --git a/gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch b/gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch new file mode 100644 index 0000000..2a61e12 --- /dev/null +++ b/gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch @@ -0,0 +1,110 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Sergio Durigan Junior +Date: Thu, 27 Jun 2019 13:14:26 -0400 +Subject: gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch + +;; Fix 'gdb crash when using PYTHONMALLOC=debug on Python' +;; RHBZ 1723564, Sergio Durigan Junior. + +Fix crash when using PYTHONMALLOC=debug (PR python/24742) + +This bug was originally reported against Fedora GDB: + + https://bugzilla.redhat.com/show_bug.cgi?id=1723564 + +The problem is that GDB will crash in the following scenario: + +- PYTHONMALLOC=debug or PYTHONDEVMODE=1 is set. + +- The Python debuginfo is installed. + +- GDB is used to debug Python. + +The crash looks like this: + + $ PYTHONMALLOC=debug gdb -args python3 -c pass + GNU gdb (GDB) Fedora 8.3-3.fc30 + Reading symbols from python3... + Reading symbols from /usr/lib/debug/usr/bin/python3.7m-3.7.3-3.fc30.x86_64.debug... + (gdb) run + Starting program: /usr/bin/python3 -c pass + Missing separate debuginfos, use: dnf debuginfo-install glibc-2.29-9.fc30.x86_64 + Debug memory block at address p=0x5603977bf330: API '' + 8098648152243306496 bytes originally requested + The 7 pad bytes at p-7 are not all FORBIDDENBYTE (0xfb): + at p-7: 0x03 *** OUCH + at p-6: 0x00 *** OUCH + at p-5: 0x00 *** OUCH + at p-4: 0x00 *** OUCH + at p-3: 0x00 *** OUCH + at p-2: 0x00 *** OUCH + at p-1: 0x00 *** OUCH + Because memory is corrupted at the start, the count of bytes requested + may be bogus, and checking the trailing pad bytes may segfault. + The 8 pad bytes at tail=0x706483999ad1f330 are Segmentation fault (core dumped) + +It's hard to determine what happens, but after doing some +investigation and talking to Victor Stinner I found that GDB should +not use the Python memory allocation functions before the Python +interpreter is initialized (which makes sense). However, we do just +that on python/python.c:do_start_initialization: + + ... + progsize = strlen (progname.get ()); + progname_copy = (wchar_t *) PyMem_Malloc ((progsize + 1) * sizeof (wchar_t)); + ... + /* Note that Py_SetProgramName expects the string it is passed to + remain alive for the duration of the program's execution, so + it is not freed after this call. */ + Py_SetProgramName (progname_copy); + ... + Py_Initialize (); + PyEval_InitThreads (); + +Upon reading the Python 3 C API documentation, I +found (https://docs.python.org/3.5/c-api/memory.html): + + To avoid memory corruption, extension writers should never try to + operate on Python objects with the functions exported by the C + library: malloc(), calloc(), realloc() and free(). This will result in + mixed calls between the C allocator and the Python memory manager with + fatal consequences, because they implement different algorithms and + operate on different heaps. However, one may safely allocate and + release memory blocks with the C library allocator for individual + purposes[...] + +And Py_SetProgramName seems like a very simple call that doesn't need +a Python-allocated memory to work on. So I'm proposing this patch, +which simply replaces PyMem_Malloc by xmalloc. + +Testing this is more complicated. First, the crash is completely +non-deterministic; I was able to reproduce it 10 times in a row, and +then I wasn't able to reproduce it anymore. I found that if you +completely remove your build directory and rebuild GDB from scratch, +you can reproduce it again confidently. And with my patch, I +confirmed that the bug doesn't manifest even in this situation. + +No regressions found. + +OK to apply? + +gdb/ChangeLog: +2019-06-28 Sergio Durigan Junior + + PR python/24742 + https://bugzilla.redhat.com/show_bug.cgi?id=1723564 + * python/python.c (do_start_initialization): Use 'xmalloc' + instead of 'PyMem_Malloc'. + +diff --git a/gdb/python/python.c b/gdb/python/python.c +--- a/gdb/python/python.c ++++ b/gdb/python/python.c +@@ -1720,7 +1720,7 @@ do_start_initialization () + std::string oldloc = setlocale (LC_ALL, NULL); + setlocale (LC_ALL, ""); + progsize = strlen (progname.get ()); +- progname_copy = (wchar_t *) PyMem_Malloc ((progsize + 1) * sizeof (wchar_t)); ++ progname_copy = (wchar_t *) xmalloc ((progsize + 1) * sizeof (wchar_t)); + if (!progname_copy) + { + fprintf (stderr, "out of memory\n"); diff --git a/gdb-suppress-sigttou-when-handling-errors.patch b/gdb-suppress-sigttou-when-handling-errors.patch deleted file mode 100644 index 1e536d7..0000000 --- a/gdb-suppress-sigttou-when-handling-errors.patch +++ /dev/null @@ -1,173 +0,0 @@ -From 766f883622ef008230250aa5aecef9fb9b29f233 Mon Sep 17 00:00:00 2001 -From: Alan Hayward -Date: Tue, 28 May 2019 10:07:54 +0100 -Subject: [PATCH] Suppress SIGTTOU when handling errors - -Calls to error () can cause SIGTTOU to send gdb to the background. - -For example, on an Arm build: - (gdb) b main - Breakpoint 1 at 0x10774: file /build/gdb/testsuite/../../../src/binutils-gdb/gdb/testsuite/gdb.base/watchpoint.c, line 174. - (gdb) r - Starting program: /build/gdb/testsuite/outputs/gdb.base/watchpoint/watchpoint - - [1]+ Stopped ../gdb ./outputs/gdb.base/watchpoint/watchpoint - localhost$ fg - ../gdb ./outputs/gdb.base/watchpoint/watchpoint - Cannot parse expression `.L1199 4@r4'. - warning: Probes-based dynamic linker interface failed. - Reverting to original interface. - -The SIGTTOU is raised whilst inside a syscall during the call to tcdrain. -Fix is to use scoped_ignore_sigttou to ensure SIGTTOU is blocked. - -In addition fix include comments - job_control is not included via terminal.h - -gdb/ChangeLog: - - * event-top.c: Remove include comment. - * inflow.c (class scoped_ignore_sigttou): Move from here... - * inflow.h (class scoped_ignore_sigttou): ...to here. - * ser-unix.c (hardwire_drain_output): Block SIGTTOU during drain. - * top.c: Remove include comment. ---- - gdb/ChangeLog | 8 ++++++++ - gdb/event-top.c | 2 +- - gdb/inflow.c | 29 ----------------------------- - gdb/inflow.h | 31 +++++++++++++++++++++++++++++++ - gdb/ser-unix.c | 4 ++++ - gdb/top.c | 2 +- - 6 files changed, 45 insertions(+), 31 deletions(-) - -diff --git a/gdb/event-top.c b/gdb/event-top.c -index 3ccf136ff12..93b7d2d28bc 100644 ---- a/gdb/event-top.c -+++ b/gdb/event-top.c -@@ -24,7 +24,7 @@ - #include "inferior.h" - #include "infrun.h" - #include "target.h" --#include "terminal.h" /* for job_control */ -+#include "terminal.h" - #include "event-loop.h" - #include "event-top.h" - #include "interps.h" -diff --git a/gdb/inflow.c b/gdb/inflow.c -index 339b55c0bc6..eba7a931f46 100644 ---- a/gdb/inflow.c -+++ b/gdb/inflow.c -@@ -106,35 +106,6 @@ static serial_ttystate initial_gdb_ttystate; - - static struct terminal_info *get_inflow_inferior_data (struct inferior *); - --/* RAII class used to ignore SIGTTOU in a scope. */ -- --class scoped_ignore_sigttou --{ --public: -- scoped_ignore_sigttou () -- { --#ifdef SIGTTOU -- if (job_control) -- m_osigttou = signal (SIGTTOU, SIG_IGN); --#endif -- } -- -- ~scoped_ignore_sigttou () -- { --#ifdef SIGTTOU -- if (job_control) -- signal (SIGTTOU, m_osigttou); --#endif -- } -- -- DISABLE_COPY_AND_ASSIGN (scoped_ignore_sigttou); -- --private: --#ifdef SIGTTOU -- sighandler_t m_osigttou = NULL; --#endif --}; -- - /* While the inferior is running, we want SIGINT and SIGQUIT to go to the - inferior only. If we have job control, that takes care of it. If not, - we save our handlers in these two variables and set SIGINT and SIGQUIT -diff --git a/gdb/inflow.h b/gdb/inflow.h -index c32aa144331..5dd5c37bd2b 100644 ---- a/gdb/inflow.h -+++ b/gdb/inflow.h -@@ -21,5 +21,36 @@ - #define INFLOW_H - - #include -+#include -+#include "common/job-control.h" -+ -+/* RAII class used to ignore SIGTTOU in a scope. */ -+ -+class scoped_ignore_sigttou -+{ -+public: -+ scoped_ignore_sigttou () -+ { -+#ifdef SIGTTOU -+ if (job_control) -+ m_osigttou = signal (SIGTTOU, SIG_IGN); -+#endif -+ } -+ -+ ~scoped_ignore_sigttou () -+ { -+#ifdef SIGTTOU -+ if (job_control) -+ signal (SIGTTOU, m_osigttou); -+#endif -+ } -+ -+ DISABLE_COPY_AND_ASSIGN (scoped_ignore_sigttou); -+ -+private: -+#ifdef SIGTTOU -+ sighandler_t m_osigttou = NULL; -+#endif -+}; - - #endif /* inflow.h */ -diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c -index 5a9965bf744..3492619f2d6 100644 ---- a/gdb/ser-unix.c -+++ b/gdb/ser-unix.c -@@ -32,6 +32,7 @@ - #include "gdbcmd.h" - #include "common/filestuff.h" - #include -+#include "inflow.h" - - struct hardwire_ttystate - { -@@ -164,6 +165,9 @@ hardwire_print_tty_state (struct serial *scb, - static int - hardwire_drain_output (struct serial *scb) - { -+ /* Ignore SIGTTOU which may occur during the drain. */ -+ scoped_ignore_sigttou ignore_sigttou; -+ - return tcdrain (scb->fd); - } - -diff --git a/gdb/top.c b/gdb/top.c -index bacd684dbaa..1e17ebee87c 100644 ---- a/gdb/top.c -+++ b/gdb/top.c -@@ -34,7 +34,7 @@ - #include "expression.h" - #include "value.h" - #include "language.h" --#include "terminal.h" /* For job_control. */ -+#include "terminal.h" - #include "common/job-control.h" - #include "annotate.h" - #include "completer.h" --- -2.21.0 - diff --git a/gdb-symtab-fix-symbol-loading-performance-regression.patch b/gdb-symtab-fix-symbol-loading-performance-regression.patch deleted file mode 100644 index c484846..0000000 --- a/gdb-symtab-fix-symbol-loading-performance-regression.patch +++ /dev/null @@ -1,97 +0,0 @@ -commit ed483764bd189d61714aa6b07104abe35469175a -Author: Tom de Vries -Date: Fri May 10 18:46:28 2019 +0200 - - [gdb/symtab] Fix symbol loading performance regression - - The commit "[gdb/symtab] Fix language of duplicate static minimal symbol" - introduces a performance regression, when loading a cc1 executable build with - -O0 -g and gcc 7.4.0. The performance regression, measured in 'real' time is - about 175%. - - The slower execution comes from the fact that the fix in symbol_set_names - makes the call to symbol_find_demangled_name unconditional. - - Fix this by reverting the commit, and redoing the fix as follows. - - Recapturing the original problem, the first time symbol_set_names is called - with gsymbol.language == lang_auto and linkage_name == "_ZL3foov", the name is - not present in the per_bfd->demangled_names_hash hash table, so - symbol_find_demangled_name is called to demangle the name, after which the - mangled/demangled pair is added to the hashtable. The call to - symbol_find_demangled_name also sets gsymbol.language to lang_cplus. - The second time symbol_set_names is called with gsymbol.language == lang_auto - and linkage_name == "_ZL3foov", the name is present in the hash table, so the - demangled name from the hash table is used. However, the language of the - symbol remains lang_auto. - - Fix this by adding a field language in struct demangled_name_entry, and using - the field in symbol_set_names to set the language of gsymbol, if necessary. - - Tested on x86_64-linux. - - gdb/ChangeLog: - - 2019-05-11 Tom de Vries - - PR symtab/24545 - * symtab.c (struct demangled_name_entry): Add language field. - (symbol_set_names): Revert "[gdb/symtab] Fix language of duplicate - static minimal symbol". Set and use language field. - -diff --git a/gdb/symtab.c b/gdb/symtab.c -index 130d5cd48f..44964533ee 100644 ---- a/gdb/symtab.c -+++ b/gdb/symtab.c -@@ -713,6 +713,7 @@ symbol_set_language (struct general_symbol_info *gsymbol, - struct demangled_name_entry - { - const char *mangled; -+ ENUM_BITFIELD(language) language : LANGUAGE_BITS; - char demangled[1]; - }; - -@@ -853,11 +854,6 @@ symbol_set_names (struct general_symbol_info *gsymbol, - else - linkage_name_copy = linkage_name; - -- /* Set the symbol language. */ -- char *demangled_name_ptr -- = symbol_find_demangled_name (gsymbol, linkage_name_copy); -- gdb::unique_xmalloc_ptr demangled_name (demangled_name_ptr); -- - entry.mangled = linkage_name_copy; - slot = ((struct demangled_name_entry **) - htab_find_slot (per_bfd->demangled_names_hash, -@@ -870,7 +866,9 @@ symbol_set_names (struct general_symbol_info *gsymbol, - || (gsymbol->language == language_go - && (*slot)->demangled[0] == '\0')) - { -- int demangled_len = demangled_name ? strlen (demangled_name.get ()) : 0; -+ char *demangled_name = symbol_find_demangled_name (gsymbol, -+ linkage_name_copy); -+ int demangled_len = demangled_name ? strlen (demangled_name) : 0; - - /* Suppose we have demangled_name==NULL, copy_name==0, and - linkage_name_copy==linkage_name. In this case, we already have the -@@ -906,12 +904,19 @@ symbol_set_names (struct general_symbol_info *gsymbol, - strcpy (mangled_ptr, linkage_name_copy); - (*slot)->mangled = mangled_ptr; - } -+ (*slot)->language = gsymbol->language; - - if (demangled_name != NULL) -- strcpy ((*slot)->demangled, demangled_name.get()); -+ { -+ strcpy ((*slot)->demangled, demangled_name); -+ xfree (demangled_name); -+ } - else - (*slot)->demangled[0] = '\0'; - } -+ else if (gsymbol->language == language_unknown -+ || gsymbol->language == language_auto) -+ gsymbol->language = (*slot)->language; - - gsymbol->name = (*slot)->mangled; - if ((*slot)->demangled[0] != '\0') diff --git a/gdb-testsuite-8.3-kfail-xfail-unsupported.patch b/gdb-testsuite-8.3-kfail-xfail-unsupported.patch new file mode 100644 index 0000000..dd82e3a --- /dev/null +++ b/gdb-testsuite-8.3-kfail-xfail-unsupported.patch @@ -0,0 +1,948 @@ +- [gdb/testsuite] Add -early pattern flag for gdb_test_multiple +- [gdb/testsuite] Mark watchthreads-reorder.exp FAIL as KFAIL +- [gdb/testsuite] Allow some tests in gdb.base/restore.exp to be unsupported +- [gdb/testsuite] Allow some tests in gdb.base/store.exp to be unsupported +- [gdb/testsuite] Require gnatmake 8 for gdb.ada/rename_subscript_param.exp +- [gdb/tdep] Handle mxcsr kernel bug on Intel Skylake CPUs +- [gdb/testsuite] Add KFAIL for missing support of reverse-debugging of vmovd +- [gdb/testsuite] Fix incomplete regexps in step-precsave.exp +- [gdb/testsuite] Add KFAIL for missing support of reverse-debugging xsave +------------------------------------------------------------ +[gdb/testsuite] Add -early pattern flag for gdb_test_multiple + +[ https://sourceware.org/ml/gdb-patches/2019-09/msg00600.html ] + +Proc gdb_test_multiple builds up and executes a gdb_expect expression with +pattern/action clauses. The clauses are either implicit (added by +gdb_test_multiple) or explicit (passed via the gdb_test_multiple parameter +user_code). + +However, there are a few implicit clauses which are inserted before the +explicit ones, making sure those take precedence. + +Add an -early pattern flag for a gdb_test_multiple user_code clause to specify +that the clause needs to be inserted before any implicit clause. + +Tested on x86_64-linux. + +gdb/testsuite/ChangeLog: + +2019-09-12 Tom de Vries + + * lib/gdb.exp (gdb_test_multiple): Handle -early pattern flag. + +------------------------------------------------------------ +[gdb/testsuite] Mark watchthreads-reorder.exp FAIL as KFAIL + +[ https://sourceware.org/ml/gdb-patches/2019-09/msg00221.html ] + +When running gdb.threads/watchthreads-reorder.exp in parallel with: +... +$ n=$(grep -c processor /proc/cpuinfo); n=$((($n + 1) / 2)); stress -c $n +... +there's a reasonable change to trigger an internal gdb error: +... +$ for n in $(seq 1 10); do ./test.sh; done 2>&1 \ + | grep "expected passes" \ + | sort \ + | uniq -c + 1 # of expected passes 14 + 2 # of expected passes 15 + 1 # of expected passes 16 + 6 # of expected passes 17 +... +which look like this in gdb.sum: +... +FAIL: gdb.threads/watchthreads-reorder.exp: reorder1: continue to breakpoint: \ + break-at-exit (GDB internal error) +... + +This FAIL is filed as PR gdb/24995 and fixed on master by commit c29705b71a +"Fix internal error and improve 'set debug infrun 1'/target wait kind trace". + +Mark this as KFAIL for the 8.3 branch. + +It's trivial to do this by adding a setup_kfail: +... ++ setup_kfail gdb/24995 "*-*-*" + gdb_continue_to_breakpoint "break-at-exit" ".*break-at-exit.*" +... +but we'll get a fair amount of KPASSES: +... +KPASS: gdb.threads/watchthreads-reorder.exp: reorder0: \ + continue to breakpoint: break-at-exit (PRMS gdb/24995) +KPASS: gdb.threads/watchthreads-reorder.exp: reorder1: \ + continue to breakpoint: break-at-exit (PRMS gdb/24995) +... + +Instead, do this more precise by only KFAILing in case the internal error is +detected. + +Tested on x86_64-linux. + +gdb/testsuite/ChangeLog: + +2019-09-12 Tom de Vries + + * gdb.threads/watchthreads-reorder.exp: Add PR gdb/24995 KFAIL. + +------------------------------------------------------------ +[gdb/testsuite] Allow some tests in gdb.base/restore.exp to be unsupported + +[ Backport of master commit 77d036789aa. ] + +We currently run into: +... +248 n = callee1 (n + l5); +(gdb) PASS: gdb.base/restore.exp: caller5 calls callee1; return callee now +print l1 +$51 = +(gdb) FAIL: gdb.base/restore.exp: caller5 calls callee1; return restored l1 \ + to 32492 +... + +The problem is that we try to access the value of l1 in function caller5, but +variable l1 has no DW_AT_location attribute. Since l1 is declared using the +register keyword, it's valid for gcc to emit no DW_AT_location at -O0. + +Change the FAIL into an UNSUPPORTED. + +Tested on x86_64-linux. + +gdb/testsuite/ChangeLog: + +2019-09-22 Tom de Vries + + * gdb.base/restore.exp: Allow register variables to be optimized out at + -O0. + +------------------------------------------------------------ +[gdb/testsuite] Allow some tests in gdb.base/store.exp to be unsupported + +[ Backport of master commit 25e5c20918a. ] + +The test-case gdb.base/store.exp fails with gcc 7.4.0: +... +nr of unexpected failures 27 +... + +The first FAIL: +... +110 l = add_float (l, r); +(gdb) PASS: gdb.base/store.exp: continue to wack_float +print l +$21 = +FAIL: gdb.base/store.exp: var float l; print old l, expecting -1 +... +relates to this bit in the test-case (compiled at -O0): +... + 106 float + 107 wack_float (register float u, register float v) + 108 { + 109 register float l = u, r = v; + 110 l = add_float (l, r); + 111 return l + r; + 112 } +... +and it expects to be able to read and modify variable l before executing line +110, but it already fails to read the value, because l has no DW_AT_location +attribute in the debug info. + +Variable l is declared with the register keyword, and GCC implements the +register keyword at -O0 like so: +... +the compiler allocates distinct stack memory for all variables that do not +have the register storage-class specifier; if register is specified, the +variable may have a shorter lifespan than the code would indicate and may +never be placed in memory. +... + +The fact that l has no DW_AT_location attribute, matches with the documented +"variable may have a shorter lifespan that code would indicate", (though it +is the most extreme case of it) so the gcc behaviour is valid. We can of +course improve gcc to generate better debuginfo (filed gcc PR91611), but +this not a wrong-debug problem. + +[ The test-case passes with gcc 4.2.1, but for the failing test discussed +above, it passes simply because it doesn't store l in a register. ] + +With the debug info missing for l, reading and setting l is unsupported, so +fix the FAIL by marking the test UNSUPPORTED instead. + +Tested on x86_64-linux. + +gdb/testsuite/ChangeLog: + +2019-09-12 Tom de Vries + + * gdb.base/store.exp: Allow register variables to be optimized out at + -O0. + +------------------------------------------------------------ +[gdb/testsuite] Require gnatmake 8 for gdb.ada/rename_subscript_param.exp + +[ Backport of master commit d1b70248bde. ] + +When running gdb.ada/rename_subscript_param.exp with gnatmake 7.4.1, we get: +... +FAIL: gdb.ada/rename_subscript_param.exp: print rename_subscript_param_b \ + before changing its value +FAIL: gdb.ada/rename_subscript_param.exp: print rename_subscript_param_b \ + after changing its value +... + +The commit last touching the test-case (afcfda091e) states: +... + The test still fails with old compilers that do not properly + generate debug info for this renaming: +... + +Fix this by requiring at least gnatmake 8 for the test-case. + +Tested on x86_64-linux. + +gdb/testsuite/ChangeLog: + +2019-09-14 Tom de Vries + + PR teststuite/24599 + * gdb.ada/rename_subscript_param.exp: Require gnatmake 8. + * lib/ada.exp (gnatmake_version_at_least): New proc. + +------------------------------------------------------------ +[gdb/tdep] Handle mxcsr kernel bug on Intel Skylake CPUs + +[ Backport of master commit 3d4352200e3. ] + +On my openSUSE Leap 15.1 x86_64 Skylake system with the default (4.12) kernel, +I run into: +... +FAIL: gdb.base/gcore.exp: corefile restored all registers +... + +The problem is that there's a difference in the mxcsr register value before +and after the gcore command: +... +- mxcsr 0x0 [ ] ++ mxcsr 0x400440 [ DAZ OM ] +... + +This can be traced back to amd64_linux_nat_target::fetch_registers, where +xstateregs is partially initialized by the ptrace call: +... + char xstateregs[X86_XSTATE_MAX_SIZE]; + struct iovec iov; + + amd64_collect_xsave (regcache, -1, xstateregs, 0); + iov.iov_base = xstateregs; + iov.iov_len = sizeof (xstateregs); + if (ptrace (PTRACE_GETREGSET, tid, + (unsigned int) NT_X86_XSTATE, (long) &iov) < 0) + perror_with_name (_("Couldn't get extended state status")); + + amd64_supply_xsave (regcache, -1, xstateregs); +... +after which amd64_supply_xsave is called. + +The amd64_supply_xsave call is supposed to only use initialized parts of +xstateregs, but due to a kernel bug on intel skylake (fixed from 4.14 onwards +by commit 0852b374173b "x86/fpu: Add FPU state copying quirk to handle XRSTOR +failure on Intel Skylake CPUs") it can happen that the mxcsr part of +xstateregs is not initialized, while amd64_supply_xsave expects it to be +initialized, which explains the FAIL mentioned above. + +Fix the undetermined behaviour by initializing xstateregs before calling +ptrace, which makes sure we get a 0x0 for mxcsr when this kernel bug occurs, +and which also happens to fix the FAIL. + +Furthermore, add an xfail for this FAIL which triggers the same kernel bug: +... +FAIL: gdb.arch/amd64-init-x87-values.exp: check_setting_mxcsr_before_enable: \ + check new value of MXCSR is still in place +... + +Both FAILs pass when using a 5.3 kernel instead on the system mentioned above. + +Tested on x86_64-linux. + +gdb/ChangeLog: + +2019-09-24 Tom de Vries + + PR gdb/23815 + * amd64-linux-nat.c (amd64_linux_nat_target::fetch_registers): + Initialize xstateregs before ptrace PTRACE_GETREGSET call. + +gdb/testsuite/ChangeLog: + +2019-09-24 Tom de Vries + + PR gdb/24598 + * gdb.arch/amd64-init-x87-values.exp: Add xfail. + +------------------------------------------------------------ +[gdb/testsuite] Add KFAIL for missing support of reverse-debugging of vmovd + +[ Backport of master commit 68f7d34dd50. ] + +On my openSUSE Leap 15.1 system I run into: +... +(gdb) PASS: gdb.reverse/step-precsave.exp: turn on process record +break 76^M +Breakpoint 2 at 0x400654: file step-reverse.c, line 76.^M +(gdb) PASS: gdb.reverse/step-precsave.exp: breakpoint at end of main +continue^M +Continuing.^M +Process record does not support instruction 0xc5 at address 0x7ffff783fc70.^M +Process record: failed to record execution log.^M +^M +Program stopped.^M +0x00007ffff783fc70 in __memset_avx2_unaligned_erms () from /lib64/libc.so.6^M +(gdb) FAIL: gdb.reverse/step-precsave.exp: run to end of main +... + +The problem is that the vmovd instruction is not supported in +reverse-debugging (PR record/23188). + +Add a KFAIL for this PR. + +Tested on x86_64-linux. + +gdb/testsuite/ChangeLog: + +2019-09-27 Tom de Vries + + PR record/23188 + * gdb.reverse/step-precsave.exp: Add kfail for PR record/23188. + +------------------------------------------------------------ +[gdb/testsuite] Fix incomplete regexps in step-precsave.exp + +[ Backport of master commit 060b3ab4eda. ] + +The commit 68f7d34dd50 "[gdb/testsuite] Add KFAIL for missing support of +reverse-debugging of vmovd" rewrites a gdb_test into a gdb_test_multiple but +forgets to add the $gdb_prompt part in the regexp. + +Add the missing parts of the regexps. + +Tested on x86_64-linux. + +gdb/testsuite/ChangeLog: + +2019-09-27 Tom de Vries + + * gdb.reverse/step-precsave.exp: Add missing $gdb_prompt in regexps. + +------------------------------------------------------------ +[gdb/testsuite] Add KFAIL for missing support of reverse-debugging xsave + +[ https://sourceware.org/ml/gdb-patches/2019-09/msg00557.html ] + +Normally the gdb.reverse/*.exp test-cases pass on my system (apart from the +record/23188 KFAIL for gdb.reverse/step-precsave.exp). But when specifying +GLIBC_TUNABLES=glibc.tune.hwcaps=-XSAVEC_Usable to force glibc to use +_dl_runtime_resolve_xsave instead of _dl_runtime_resolve_xsavec, we run into +1054 FAILs like this: +... +(gdb) PASS: gdb.reverse/sigall-reverse.exp: b gen_HUP +continue^M +Continuing.^M +Process record does not support instruction 0xfae64 at address \ + 0x7ffff7ded958.^M +Process record: failed to record execution log.^M +^M +Program stopped.^M +0x00007ffff7ded958 in _dl_runtime_resolve_xsave () from \ + /lib64/ld-linux-x86-64.so.2^M +(gdb) FAIL: gdb.reverse/sigall-reverse.exp: get signal ABRT +... + +The problem is that the xsave instruction is not supported in +reverse-debugging (PR record/25038). + +Add KFAILs for this PR. + +Tested on x86_64-linux. + +gdb/testsuite/ChangeLog: + +2019-09-27 Tom de Vries + + PR record/25038 + * gdb.reverse/sigall-precsave.exp: Add PR record/25038 KFAIL. + * gdb.reverse/sigall-reverse.exp: Same. + * gdb.reverse/solib-precsave.exp: Same. + * gdb.reverse/solib-reverse.exp: Same. + * gdb.reverse/step-precsave.exp: Same. + * gdb.reverse/until-precsave.exp: Same. + * gdb.reverse/until-reverse.exp: Same. + * lib/gdb.exp (gdb_continue_to_breakpoint): Same. + +------------------------------------------------------------ +diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp +index 3d5f8726f7f..5f1bc4d84b7 100644 +--- a/gdb/testsuite/lib/gdb.exp ++++ b/gdb/testsuite/lib/gdb.exp +@@ -798,37 +798,44 @@ proc gdb_test_multiple { command message user_code } { + set subst_code [uplevel list $subst_code] + + set processed_code "" ++ set early_processed_code "" ++ set current_list processed_code + set patterns "" + set expecting_action 0 + set expecting_arg 0 + foreach item $user_code subst_item $subst_code { + if { $item == "-n" || $item == "-notransfer" || $item == "-nocase" } { +- lappend processed_code $item ++ lappend $current_list $item + continue + } + if { $item == "-indices" || $item == "-re" || $item == "-ex" } { +- lappend processed_code $item ++ lappend $current_list $item ++ continue ++ } ++ if { $item == "-early" } { ++ set current_list early_processed_code + continue + } + if { $item == "-timeout" || $item == "-i" } { + set expecting_arg 1 +- lappend processed_code $item ++ lappend $current_list $item + continue + } + if { $expecting_arg } { + set expecting_arg 0 +- lappend processed_code $subst_item ++ lappend $current_list $subst_item + continue + } + if { $expecting_action } { +- lappend processed_code "uplevel [list $item]" ++ lappend $current_list "uplevel [list $item]" + set expecting_action 0 + # Cosmetic, no effect on the list. +- append processed_code "\n" ++ append $current_list "\n" ++ set current_list processed_code + continue + } + set expecting_action 1 +- lappend processed_code $subst_item ++ lappend $current_list $subst_item + if {$patterns != ""} { + append patterns "; " + } +@@ -891,7 +898,8 @@ proc gdb_test_multiple { command message user_code } { + } + } + +- set code { ++ set code $early_processed_code ++ append code { + -re ".*A problem internal to GDB has been detected" { + fail "$message (GDB internal error)" + gdb_internal_error_resync +diff --git a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp +index 9bbbb6f2b8b..2e90870087d 100644 +--- a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp ++++ b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp +@@ -90,5 +90,19 @@ foreach reorder {0 1} { with_test_prefix "reorder$reorder" { + # found in the DEBUG_INFRUN code path. + gdb_test "set debug infrun 1" + +- gdb_continue_to_breakpoint "break-at-exit" ".*break-at-exit.*" ++ # Do: ++ # gdb_continue_to_breakpoint "break-at-exit" ".*break-at-exit.*" ++ # with setup_kfail. ++ set msg "continue to breakpoint: break-at-exit" ++ set pass_pattern "(?:Breakpoint|Temporary breakpoint) .* (at|in) .*break-at-exit.*" ++ set kfail_pattern "internal-error: inferior\\* find_inferior_pid\\(int\\): Assertion .pid != 0. failed\\." ++ gdb_test_multiple "continue" $msg { ++ -early -re "$kfail_pattern" { ++ setup_kfail gdb/24995 "*-*-*" ++ exp_continue ++ } ++ -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { ++ pass $msg ++ } ++ } + }} +diff --git a/gdb/testsuite/gdb.base/restore.exp b/gdb/testsuite/gdb.base/restore.exp +index 947fe58be47..56c2f5e3dce 100644 +--- a/gdb/testsuite/gdb.base/restore.exp ++++ b/gdb/testsuite/gdb.base/restore.exp +@@ -73,8 +73,17 @@ proc restore_tests { } { + # they should be. + for {set var 1} {$var <= $c} {incr var} { + set expected [expr 0x7eeb + $var] +- gdb_test "print l$var" " = $expected" \ +- "caller$c calls callee$e; return restored l$var to $expected" ++ set test "caller$c calls callee$e; return restored l$var to $expected" ++ set pass_pattern " = $expected" ++ set unsupported_pattern " = " ++ gdb_test_multiple "print l$var" $test { ++ -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { ++ pass $test ++ } ++ -re "\[\r\n\]*(?:$unsupported_pattern)\[\r\n\]+$gdb_prompt $" { ++ unsupported $test ++ } ++ } + } + } + } +diff --git a/gdb/testsuite/gdb.base/store.exp b/gdb/testsuite/gdb.base/store.exp +index c5a7584101a..9c19ce15a7b 100644 +--- a/gdb/testsuite/gdb.base/store.exp ++++ b/gdb/testsuite/gdb.base/store.exp +@@ -55,18 +55,29 @@ proc check_set { t l r new add } { + } + } + +- gdb_test "print l" " = ${l}" \ +- "${prefix}; print old l, expecting ${l}" +- gdb_test "print r" " = ${r}" \ +- "${prefix}; print old r, expecting ${r}" +- gdb_test_no_output "set variable l = 4" \ +- "${prefix}; setting l to 4" +- gdb_test "print l" " = ${new}" \ +- "${prefix}; print new l, expecting ${new}" +- gdb_test "next" "return l \\+ r;" \ +- "${prefix}; next over add call" +- gdb_test "print l" " = ${add}" \ +- "${prefix}; print incremented l, expecting ${add}" ++ set supported 1 ++ set test "${prefix}; print old l, expecting ${l}" ++ gdb_test_multiple "print l" "$test" { ++ -re " = \r\n$gdb_prompt $" { ++ unsupported $test ++ set supported 0 ++ } ++ -re " = ${l}\r\n$gdb_prompt $" { ++ pass $test ++ } ++ } ++ if { $supported } { ++ gdb_test "print r" " = ${r}" \ ++ "${prefix}; print old r, expecting ${r}" ++ gdb_test_no_output "set variable l = 4" \ ++ "${prefix}; setting l to 4" ++ gdb_test "print l" " = ${new}" \ ++ "${prefix}; print new l, expecting ${new}" ++ gdb_test "next" "return l \\+ r;" \ ++ "${prefix}; next over add call" ++ gdb_test "print l" " = ${add}" \ ++ "${prefix}; print incremented l, expecting ${add}" ++ } + } + + check_set "charest" "-1 .*" "-2 .*" "4 ..004." "2 ..002." +@@ -81,20 +92,34 @@ check_set "doublest" "-1" "-2" "4" "2" + # + + proc up_set { t l r new } { ++ global gdb_prompt ++ + set prefix "upvar ${t} l" + gdb_test "tbreak add_${t}" + gdb_test "continue" "return u . v;" \ + "continue to add_${t}" + gdb_test "up" "l = add_${t} .l, r.;" \ + "${prefix}; up" +- gdb_test "print l" " = ${l}" \ +- "${prefix}; print old l, expecting ${l}" +- gdb_test "print r" " = ${r}" \ +- "${prefix}; print old r, expecting ${r}" +- gdb_test_no_output "set variable l = 4" \ +- "${prefix}; set l to 4" +- gdb_test "print l" " = ${new}" \ +- "${prefix}; print new l, expecting ${new}" ++ ++ set supported 1 ++ set test "${prefix}; print old l, expecting ${l}" ++ gdb_test_multiple "print l" "$test" { ++ -re " = \r\n$gdb_prompt $" { ++ unsupported $test ++ set supported 0 ++ } ++ -re " = ${l}\r\n$gdb_prompt $" { ++ pass $test ++ } ++ } ++ if { $supported } { ++ gdb_test "print r" " = ${r}" \ ++ "${prefix}; print old r, expecting ${r}" ++ gdb_test_no_output "set variable l = 4" \ ++ "${prefix}; set l to 4" ++ gdb_test "print l" " = ${new}" \ ++ "${prefix}; print new l, expecting ${new}" ++ } + } + + up_set "charest" "-1 .*" "-2 .*" "4 ..004." +diff --git a/gdb/testsuite/gdb.ada/rename_subscript_param.exp b/gdb/testsuite/gdb.ada/rename_subscript_param.exp +index ffcfa50df33..fd8208825a0 100644 +--- a/gdb/testsuite/gdb.ada/rename_subscript_param.exp ++++ b/gdb/testsuite/gdb.ada/rename_subscript_param.exp +@@ -15,6 +15,10 @@ + + load_lib "ada.exp" + ++if { ![gnatmake_version_at_least 8] } { ++ return -1 ++} ++ + standard_ada_testfile pb30_012 + + if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } { +diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp +index ee9ade16ae5..b10558811fb 100644 +--- a/gdb/testsuite/lib/ada.exp ++++ b/gdb/testsuite/lib/ada.exp +@@ -78,3 +78,23 @@ proc standard_ada_testfile {base_file {dir ""}} { + set srcfile $srcdir/$subdir/$testdir/$testfile.adb + set binfile [standard_output_file $testfile] + } ++ ++# Return 1 if gnatmake is at least version $MAJOR.x.x ++ ++proc gnatmake_version_at_least { major } { ++ set gnatmake [gdb_find_gnatmake] ++ set gnatmake [lindex [split $gnatmake] 0] ++ set output [exec $gnatmake --version] ++ if { [regexp {GNATMAKE ([^ .]+).([^ .]+).([^ .]+)} $output \ ++ match gnatmake_major gnatmake_minor gnatmake_micro] } { ++ if { $gnatmake_major >= $major } { ++ return 1 ++ } else { ++ return 0 ++ } ++ } ++ ++ # Unknown, return 1 ++ return 1 ++} ++ +diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c +index 8d0e8eb35cd..b56917c2bc6 100644 +--- a/gdb/amd64-linux-nat.c ++++ b/gdb/amd64-linux-nat.c +@@ -238,6 +238,12 @@ amd64_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum) + char xstateregs[X86_XSTATE_MAX_SIZE]; + struct iovec iov; + ++ /* Pre-4.14 kernels have a bug (fixed by commit 0852b374173b ++ "x86/fpu: Add FPU state copying quirk to handle XRSTOR failure on ++ Intel Skylake CPUs") that sometimes causes the mxcsr location in ++ xstateregs not to be copied by PTRACE_GETREGSET. Make sure that ++ the location is at least initialized with a defined value. */ ++ memset (xstateregs, 0, sizeof (xstateregs)); + iov.iov_base = xstateregs; + iov.iov_len = sizeof (xstateregs); + if (ptrace (PTRACE_GETREGSET, tid, +diff --git a/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp b/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp +index cdf92dcd377..5fd18dbb794 100644 +--- a/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp ++++ b/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp +@@ -116,7 +116,7 @@ proc_with_prefix check_x87_regs_around_init {} { + # nop that does not enable any FP features). Finally check that the + # mxcsr register still has the value we set. + proc_with_prefix check_setting_mxcsr_before_enable {} { +- global binfile ++ global binfile gdb_prompt + + clean_restart ${binfile} + +@@ -127,7 +127,22 @@ proc_with_prefix check_setting_mxcsr_before_enable {} { + + gdb_test_no_output "set \$mxcsr=0x9f80" "set a new value for MXCSR" + gdb_test "stepi" "fwait" "step forward one instruction for mxcsr test" +- gdb_test "p/x \$mxcsr" " = 0x9f80" "check new value of MXCSR is still in place" ++ ++ set test "check new value of MXCSR is still in place" ++ set pass_pattern " = 0x9f80" ++ # Pre-4.14 kernels have a bug (fixed by commit 0852b374173b "x86/fpu: ++ # Add FPU state copying quirk to handle XRSTOR failure on Intel Skylake ++ # CPUs") that causes mxcsr not to be copied, in which case we get 0 instead of ++ # the just saved value. ++ set xfail_pattern " = 0x0" ++ gdb_test_multiple "p/x \$mxcsr" $test { ++ -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { ++ pass $test ++ } ++ -re "\[\r\n\]*(?:$xfail_pattern)\[\r\n\]+$gdb_prompt $" { ++ xfail $test ++ } ++ } + } + + # Start the test file, all FP features will be disabled. Set new +diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp +index 7443995c007..f5e15510e1f 100644 +--- a/gdb/testsuite/gdb.reverse/step-precsave.exp ++++ b/gdb/testsuite/gdb.reverse/step-precsave.exp +@@ -46,7 +46,15 @@ gdb_test "break $end_of_main" \ + + # This can take awhile. + with_timeout_factor 20 { +- gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" ++ set test "run to end of main" ++ gdb_test_multiple "continue" $test { ++ -re "Breakpoint .* end of main .*" { ++ pass $test ++ } ++ -re "Process record does not support instruction 0xc5 at.*$gdb_prompt $" { ++ kfail "record/23188" $test ++ } ++ } + } + + # So can this, against gdbserver, for example. +diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp +index f5e15510e1f..2073b8a1542 100644 +--- a/gdb/testsuite/gdb.reverse/step-precsave.exp ++++ b/gdb/testsuite/gdb.reverse/step-precsave.exp +@@ -47,11 +47,13 @@ gdb_test "break $end_of_main" \ + # This can take awhile. + with_timeout_factor 20 { + set test "run to end of main" ++ set pass_pattern "Breakpoint .* end of main .*" ++ set kfail_pattern "Process record does not support instruction 0xc5 at.*" + gdb_test_multiple "continue" $test { +- -re "Breakpoint .* end of main .*" { ++ -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { + pass $test + } +- -re "Process record does not support instruction 0xc5 at.*$gdb_prompt $" { ++ -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { + kfail "record/23188" $test + } + } +diff --git a/gdb/testsuite/gdb.reverse/sigall-precsave.exp b/gdb/testsuite/gdb.reverse/sigall-precsave.exp +index 79a1e7282b6..ccdfde407fc 100644 +--- a/gdb/testsuite/gdb.reverse/sigall-precsave.exp ++++ b/gdb/testsuite/gdb.reverse/sigall-precsave.exp +@@ -258,14 +258,20 @@ foreach sig $signals { + } + } + +-gdb_test_multiple "continue" "continue" { ++set kfail_pattern "Process record does not support instruction 0xfae64 at.*" ++set test "run to end of main" ++gdb_test_multiple "continue" $test { + -re "Breakpoint .* end of main .*$gdb_prompt $" { +- pass "run to end of main" ++ pass $test + } + -re "Breakpoint .* handle_.*$gdb_prompt $" { + send_gdb "continue\n" + exp_continue + } ++ -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { ++ kfail "gdb/25038" $test ++ return -1 ++ } + } + + delete_breakpoints +@@ -289,8 +295,12 @@ set sig_supported 1 + set thissig "ABRT" + + # test signal handling ++set record_instruction_kfail 0 + foreach sig [lrange $signals 1 end] { + test_one_sig $sig ++ if { $record_instruction_kfail } { ++ return -1 ++ } + } + + # The last signal (SIGTERM) gets handled slightly differently because +diff --git a/gdb/testsuite/gdb.reverse/sigall-reverse.exp b/gdb/testsuite/gdb.reverse/sigall-reverse.exp +index c734fe8e17a..884a00c5dcf 100644 +--- a/gdb/testsuite/gdb.reverse/sigall-reverse.exp ++++ b/gdb/testsuite/gdb.reverse/sigall-reverse.exp +@@ -37,6 +37,7 @@ proc test_one_sig {nextsig} { + global sig_supported + global gdb_prompt + global thissig ++ global record_instruction_kfail + + set this_sig_supported $sig_supported + gdb_test "handle SIG$thissig stop print" \ +@@ -51,6 +52,7 @@ proc test_one_sig {nextsig} { + setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu" + } + set testmsg "get signal $thissig" ++ set kfail_pattern "Process record does not support instruction 0xfae64 at.*" + gdb_test_multiple "continue" $testmsg { + -re "Program received signal SIG$thissig.*handle_$thissig.*$gdb_prompt $" { + fail "$testmsg (wrong location)" +@@ -62,6 +64,11 @@ proc test_one_sig {nextsig} { + xfail $testmsg + set need_another_continue 0 + } ++ -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { ++ kfail "gdb/25038" "$testmsg" ++ set record_instruction_kfail 1 ++ return ++ } + } + } + +@@ -237,8 +244,12 @@ set sig_supported 1 + set thissig "ABRT" + + # test signal handling ++set record_instruction_kfail 0 + foreach sig [lrange $signals 1 end] { + test_one_sig $sig ++ if { $record_instruction_kfail } { ++ return -1 ++ } + } + + # The last signal (SIGTERM) gets handled slightly differently because +diff --git a/gdb/testsuite/gdb.reverse/solib-precsave.exp b/gdb/testsuite/gdb.reverse/solib-precsave.exp +index 574d79816db..a3f874c09b7 100644 +--- a/gdb/testsuite/gdb.reverse/solib-precsave.exp ++++ b/gdb/testsuite/gdb.reverse/solib-precsave.exp +@@ -91,7 +91,18 @@ gdb_test "break $end_of_main" \ + "Breakpoint $decimal at .*$srcfile, line $end_of_main\." \ + "breakpoint at end of main" + +-gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" ++set test "run to end of main" ++set pass_pattern "Breakpoint .* end of main .*" ++set kfail_pattern "Process record does not support instruction 0xfae64 at.*" ++gdb_test_multiple "continue" $test { ++ -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { ++ pass $test ++ } ++ -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { ++ kfail "gdb/25038" $test ++ return -1 ++ } ++} + + gdb_test "record save $precsave" \ + "Saved core file $precsave with execution log\." \ +diff --git a/gdb/testsuite/gdb.reverse/solib-reverse.exp b/gdb/testsuite/gdb.reverse/solib-reverse.exp +index 77c321388b4..53b35239f81 100644 +--- a/gdb/testsuite/gdb.reverse/solib-reverse.exp ++++ b/gdb/testsuite/gdb.reverse/solib-reverse.exp +@@ -86,7 +86,18 @@ if [supports_process_record] { + + set end_part_one [gdb_get_line_number " end part one" "$srcfile"] + set end_part_two [gdb_get_line_number " end part two" "$srcfile"] +-gdb_test "until $end_part_one" " end part one.*" "run until end part one" ++set test "run until end part one" ++set pass_pattern " end part one.*" ++set kfail_pattern "Process record does not support instruction 0xfae64 at.*" ++gdb_test_multiple "until $end_part_one" $test { ++ -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { ++ pass $test ++ } ++ -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { ++ kfail "gdb/25038" $test ++ return -1 ++ } ++} + + gdb_test "reverse-step" " shr1 three .*" "reverse-step third shr1" + gdb_test "reverse-step" " shr1 two .*" "reverse-step second shr1" +diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp +index 2073b8a1542..72ee279f806 100644 +--- a/gdb/testsuite/gdb.reverse/step-precsave.exp ++++ b/gdb/testsuite/gdb.reverse/step-precsave.exp +@@ -49,6 +49,7 @@ with_timeout_factor 20 { + set test "run to end of main" + set pass_pattern "Breakpoint .* end of main .*" + set kfail_pattern "Process record does not support instruction 0xc5 at.*" ++ set kfail2_pattern "Process record does not support instruction 0xfae64 at.*" + gdb_test_multiple "continue" $test { + -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { + pass $test +@@ -56,6 +57,9 @@ with_timeout_factor 20 { + -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { + kfail "record/23188" $test + } ++ -re "\[\r\n\]*(?:$kfail2_pattern)\[\r\n\]+$gdb_prompt $" { ++ kfail "record/25038" $test ++ } + } + } + +diff --git a/gdb/testsuite/gdb.reverse/until-precsave.exp b/gdb/testsuite/gdb.reverse/until-precsave.exp +index baf21ab7ad2..1f09df193fd 100644 +--- a/gdb/testsuite/gdb.reverse/until-precsave.exp ++++ b/gdb/testsuite/gdb.reverse/until-precsave.exp +@@ -50,7 +50,18 @@ gdb_test "break $end_of_main" \ + + # This can take awhile. + with_timeout_factor 20 { +- gdb_test "continue" "Breakpoint .* set breakpoint 10a here .*" "run to end of main" ++ set test "run to end of main" ++ set pass_pattern "Breakpoint .* set breakpoint 10a here .*" ++ set kfail_pattern "Process record does not support instruction 0xfae64 at.*" ++ gdb_test_multiple "continue" $test { ++ -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { ++ pass $test ++ } ++ -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { ++ kfail "gdb/25038" $test ++ return -1 ++ } ++ } + } + + # So can this, against gdbserver, for example. +diff --git a/gdb/testsuite/gdb.reverse/until-reverse.exp b/gdb/testsuite/gdb.reverse/until-reverse.exp +index 2e26de3ce7b..804e07f46ca 100644 +--- a/gdb/testsuite/gdb.reverse/until-reverse.exp ++++ b/gdb/testsuite/gdb.reverse/until-reverse.exp +@@ -49,9 +49,18 @@ gdb_test "until $bp_location1" \ + + # Advance up to factorial, outer invocation + # +-gdb_test "advance factorial" \ +- "factorial .value=6..*$srcfile:$bp_location7.*" \ +- "advance to factorial" ++set test "advance to factorial" ++set pass_pattern "factorial .value=6..*$srcfile:$bp_location7.*" ++set kfail_pattern "Process record does not support instruction 0xfae64 at.*" ++gdb_test_multiple "advance factorial" $test { ++ -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" { ++ pass "$test" ++ } ++ -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { ++ kfail "gdb/25038" $test ++ return -1 ++ } ++} + + # At this point, 'until' should continue the inferior up to when all the + # inner invocations of factorial() are completed and we are back at this +diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp +index 5f1bc4d84b7..0d5447dd10c 100644 +--- a/gdb/testsuite/lib/gdb.exp ++++ b/gdb/testsuite/lib/gdb.exp +@@ -633,10 +633,14 @@ proc gdb_continue_to_breakpoint {name {location_pattern .*}} { + global gdb_prompt + set full_name "continue to breakpoint: $name" + ++ set kfail_pattern "Process record does not support instruction 0xfae64 at.*" + gdb_test_multiple "continue" $full_name { + -re "(?:Breakpoint|Temporary breakpoint) .* (at|in) $location_pattern\r\n$gdb_prompt $" { + pass $full_name + } ++ -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" { ++ kfail "gdb/25038" $full_name ++ } + } + } + diff --git a/gdb-testsuite-pie-no-pie.patch b/gdb-testsuite-pie-no-pie.patch index 7b18f79..ddb6e09 100644 --- a/gdb-testsuite-pie-no-pie.patch +++ b/gdb-testsuite-pie-no-pie.patch @@ -1,4 +1,3 @@ -- Testsuite: Ensure pie is disabled on some tests - Testsuite: Remove pie from trace tests - [gdb/testsuite] Fail in gdb_compile if nopie results in PIE executable - [gdb/testsuite] Fail in gdb_compile if pie results in non-PIE executable @@ -107,130 +106,6 @@ gdb/testsuite/ChangeLog: --------------------------------------------------------- -Testsuite: Ensure pie is disabled on some tests - -Recent versions of Ubuntu and Debian default GCC to enable pie. - -In dump.exp, pie will causes addresses to be out of range for IHEX. - -In break-interp.exp, pie is explicitly set for some tests and assumed -to be disabled for the remainder. - -Ensure pie is disabled for these tests when required. - -In addition, add a pie option to gdb_compile to match the nopie option -and simplify use. - -gdb/testsuite/ChangeLog: - - * README: Add pie options. - * gdb.base/break-interp.exp: Ensure pie is disabled. - * gdb.base/dump.exp: Likewise. - * lib/gdb.exp (gdb_compile): Add pie option. - ---------------------------------------------------------- - -diff --git a/gdb/testsuite/README b/gdb/testsuite/README -index b5e75b9a79..db90ea4698 100644 ---- a/gdb/testsuite/README -+++ b/gdb/testsuite/README -@@ -482,6 +482,16 @@ gdb,no_thread_names - - The target doesn't support thread names. - -+gdb,pie_flag -+ -+ The flag required to force the compiler to produce position-independent -+ executables. -+ -+gdb,pie_ldflag -+ -+ The flag required to force the linker to produce position-independent -+ executables. -+ - gdb,nopie_flag - - The flag required to force the compiler to produce non-position-independent -diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp -index f85e8a650a..51e31f6503 100644 ---- a/gdb/testsuite/gdb.base/break-interp.exp -+++ b/gdb/testsuite/gdb.base/break-interp.exp -@@ -625,8 +625,10 @@ foreach ldprelink {NO YES} { - lappend opts {debug} - } - if {$binpie != "NO"} { -- lappend opts {additional_flags=-fPIE} -- lappend opts {ldflags=-pie} -+ lappend opts {pie} -+ } else { -+ # Debian9/Ubuntu16.10 onwards default to PIE enabled. Ensure it is disabled. -+ lappend opts {nopie} - } - - set dir ${exec}.d -diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp -index 44b0988b80..52ba5f8ebe 100644 ---- a/gdb/testsuite/gdb.base/dump.exp -+++ b/gdb/testsuite/gdb.base/dump.exp -@@ -36,6 +36,10 @@ if {[istarget "spu*-*-*"]} then { - set is64bitonly "yes" - } - -+# Debian9/Ubuntu16.10 onwards default to PIE enabled. Ensure it is disabled as -+# this causes addresses to be out of range for IHEX. -+lappend options {nopie} -+ - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } { - untested "failed to compile" - return -1 -diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp -index 36f167336c..3d5f8726f7 100644 ---- a/gdb/testsuite/lib/gdb.exp -+++ b/gdb/testsuite/lib/gdb.exp -@@ -3492,6 +3492,7 @@ set gdb_saved_set_unbuffered_mode_obj "" - # dynamically load libraries at runtime. For example, on Linux, this adds - # -ldl so that the test can use dlopen. - # - nowarnings: Inhibit all compiler warnings. -+# - pie: Force creation of PIE executables. - # - nopie: Prevent creation of PIE executables. - # - # And here are some of the not too obscure options understood by DejaGnu that -@@ -3630,8 +3631,33 @@ proc gdb_compile {source dest type options} { - set options [lreplace $options $nowarnings $nowarnings $flag] - } - -- # Replace the "nopie" option with the appropriate additional_flags -- # to disable PIE executables. -+ # Replace the "pie" option with the appropriate compiler and linker flags -+ # to enable PIE executables. -+ set pie [lsearch -exact $options pie] -+ if {$pie != -1} { -+ if [target_info exists gdb,pie_flag] { -+ set flag "additional_flags=[target_info gdb,pie_flag]" -+ } else { -+ # For safety, use fPIE rather than fpie. On AArch64, m68k, PowerPC -+ # and SPARC, fpie can cause compile errors due to the GOT exceeding -+ # a maximum size. On other architectures the two flags are -+ # identical (see the GCC manual). Note Debian9 and Ubuntu16.10 -+ # onwards default GCC to using fPIE. If you do require fpie, then -+ # it can be set using the pie_flag. -+ set flag "additional_flags=-fPIE" -+ } -+ set options [lreplace $options $pie $pie $flag] -+ -+ if [target_info exists gdb,pie_ldflag] { -+ set flag "ldflags=[target_info gdb,pie_ldflag]" -+ } else { -+ set flag "ldflags=-pie" -+ } -+ lappend options "$flag" -+ } -+ -+ # Replace the "nopie" option with the appropriate linker flag to disable -+ # PIE executables. There are no compiler flags for this option. - set nopie [lsearch -exact $options nopie] - if {$nopie != -1} { - if [target_info exists gdb,nopie_flag] { diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp index 0f60153cb5..24e097135f 100644 --- a/gdb/testsuite/gdb.trace/backtrace.exp diff --git a/gdb-x86_64-i386-syscall-restart-master.patch b/gdb-x86_64-i386-syscall-restart-master.patch deleted file mode 100644 index 96cd220..0000000 --- a/gdb-x86_64-i386-syscall-restart-master.patch +++ /dev/null @@ -1,212 +0,0 @@ -commit 3f52fdbcb599f76b4838020721ca6c9f1cc28f84 -Author: Kevin Buettner -Date: Sat Mar 16 12:40:01 2019 -0700 - - Fix amd64->i386 linux syscall restart problem - - This commit fixes some failures in gdb.base/interrupt.exp - when debugging a 32-bit i386 linux inferior from an amd64 host. - - When running the following test... - - make check RUNTESTFLAGS="--target_board unix/-m32 interrupt.exp" - - ... without this commit, I see the following output: - - FAIL: gdb.base/interrupt.exp: continue (the program exited) - FAIL: gdb.base/interrupt.exp: echo data - FAIL: gdb.base/interrupt.exp: Send Control-C, second time - FAIL: gdb.base/interrupt.exp: signal SIGINT (the program is no longer running) - ERROR: Undefined command "". - ERROR: GDB process no longer exists - - === gdb Summary === - - When the test is run with this commit in place, we see 12 passes - instead. This is the desired behavior. - - Analysis: - - On Linux, when a syscall is interrupted by a signal, the syscall - may return -ERESTARTSYS when a signal occurs. Doing so indicates that - the syscall is restartable. Then, depending on settings associated - with the signal handler, and after the signal handler is called, the - kernel can then either return -EINTR or can cause the syscall to be - restarted. In this discussion, we are concerned with the latter - case. - - On i386, the kernel returns this status via the EAX register. - - When debugging a 32-bit (i386) process from a 64-bit (amd64) - GDB, the debugger fetches 64-bit registers even though the - process being debugged is 32-bit. Since we're debugging a 32-bit - target, only 32 bits are being saved in the register cache. - Now, ideally, GDB would save all 64-bits in the regcache and - then would be able to restore those same values when it comes - time to continue the target. I've looked into doing this, but - it's not easy and I don't see many benefits to doing so. One - benefit, however, would be that EAX would appear as a negative - value for doing syscall restarts. - - At the moment, GDB is setting the high 32 bits of RAX (and other - registers too) to 0. So, when GDB restores EAX just prior to - a syscall restart, the high 32 bits of RAX are zeroed, thus making - it look like a positive value. For this particular purpose, we - need to sign extend EAX so that RAX will appear as a negative - value when EAX is set to -ERESTARTSYS. This in turn will cause - the signal handling code in the kernel to recognize -ERESTARTSYS - which will in turn cause the syscall to be restarted. - - This commit is based on work by Jan Kratochvil from 2009: - - https://sourceware.org/ml/gdb-patches/2009-11/msg00592.html - - Jan's patch had the sign extension code in amd64-nat.c. Several - other native targets make use of this code, so it seemed better - to move the sign extension code to a linux specific file. I - also added similar code to gdbserver. - - Another approach is to fix the problem in the kernel. Hui Zhu - tried to get a fix into the kernel back in 2014, but it was not - accepted. Discussion regarding this approach may be found here: - - https://lore.kernel.org/patchwork/patch/457841/ - - Even if a fix were to be put into the kernel, we'd still need - some kind of fix in GDB in order to support older kernels. - - Finally, I'll note that Fedora has been carrying a similar patch for - at least nine years. Other distributions, including RHEL and CentOS - have picked up this change and have been using it too. - - gdb/ChangeLog: - - * amd64-linux-nat.c (amd64_linux_collect_native_gregset): New - function. - (fill_gregset): Call amd64_linux_collect_native_gregset instead - of amd64_collect_native_gregset. - (amd64_linux_nat_target::store_registers): Likewise. - - gdb/gdbserver/ChangeLog: - - * linux-x86-low.c (x86_fill_gregset): Sign extend EAX value - when using a 64-bit gdbserver. - -diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c -index a0bb105f5a..8d0e8eb35c 100644 ---- a/gdb/amd64-linux-nat.c -+++ b/gdb/amd64-linux-nat.c -@@ -92,6 +92,71 @@ static int amd64_linux_gregset32_reg_offset[] = - /* Transfering the general-purpose registers between GDB, inferiors - and core files. */ - -+/* See amd64_collect_native_gregset. This linux specific version handles -+ issues with negative EAX values not being restored correctly upon syscall -+ return when debugging 32-bit targets. It has no effect on 64-bit -+ targets. */ -+ -+static void -+amd64_linux_collect_native_gregset (const struct regcache *regcache, -+ void *gregs, int regnum) -+{ -+ amd64_collect_native_gregset (regcache, gregs, regnum); -+ -+ struct gdbarch *gdbarch = regcache->arch (); -+ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) -+ { -+ /* Sign extend EAX value to avoid potential syscall restart -+ problems. -+ -+ On Linux, when a syscall is interrupted by a signal, the -+ (kernel function implementing the) syscall may return -+ -ERESTARTSYS when a signal occurs. Doing so indicates that -+ the syscall is restartable. Then, depending on settings -+ associated with the signal handler, and after the signal -+ handler is called, the kernel can then either return -EINTR -+ or it can cause the syscall to be restarted. We are -+ concerned with the latter case here. -+ -+ On (32-bit) i386, the status (-ERESTARTSYS) is placed in the -+ EAX register. When debugging a 32-bit process from a 64-bit -+ (amd64) GDB, the debugger fetches 64-bit registers even -+ though the process being debugged is only 32-bit. The -+ register cache is only 32 bits wide though; GDB discards the -+ high 32 bits when placing 64-bit values in the 32-bit -+ regcache. Normally, this is not a problem since the 32-bit -+ process should only care about the lower 32-bit portions of -+ these registers. That said, it can happen that the 64-bit -+ value being restored will be different from the 64-bit value -+ that was originally retrieved from the kernel. The one place -+ (that we know of) where it does matter is in the kernel's -+ syscall restart code. The kernel's code for restarting a -+ syscall after a signal expects to see a negative value -+ (specifically -ERESTARTSYS) in the 64-bit RAX register in -+ order to correctly cause a syscall to be restarted. -+ -+ The call to amd64_collect_native_gregset, above, is setting -+ the high 32 bits of RAX (and other registers too) to 0. For -+ syscall restart, we need to sign extend EAX so that RAX will -+ appear as a negative value when EAX is set to -ERESTARTSYS. -+ This in turn will cause the signal handling code in the -+ kernel to recognize -ERESTARTSYS which will in turn cause the -+ syscall to be restarted. -+ -+ The test case gdb.base/interrupt.exp tests for this problem. -+ Without this sign extension code in place, it'll show -+ a number of failures when testing against unix/-m32. */ -+ -+ if (regnum == -1 || regnum == I386_EAX_REGNUM) -+ { -+ void *ptr = ((gdb_byte *) gregs -+ + amd64_linux_gregset32_reg_offset[I386_EAX_REGNUM]); -+ -+ *(int64_t *) ptr = *(int32_t *) ptr; -+ } -+ } -+} -+ - /* Fill GDB's register cache with the general-purpose register values - in *GREGSETP. */ - -@@ -109,7 +174,7 @@ void - fill_gregset (const struct regcache *regcache, - elf_gregset_t *gregsetp, int regnum) - { -- amd64_collect_native_gregset (regcache, gregsetp, regnum); -+ amd64_linux_collect_native_gregset (regcache, gregsetp, regnum); - } - - /* Transfering floating-point registers between GDB, inferiors and cores. */ -@@ -237,7 +302,7 @@ amd64_linux_nat_target::store_registers (struct regcache *regcache, int regnum) - if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) - perror_with_name (_("Couldn't get registers")); - -- amd64_collect_native_gregset (regcache, ®s, regnum); -+ amd64_linux_collect_native_gregset (regcache, ®s, regnum); - - if (ptrace (PTRACE_SETREGS, tid, 0, (long) ®s) < 0) - perror_with_name (_("Couldn't write registers")); -diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c -index 029796e361..dd7673126e 100644 ---- a/gdb/gdbserver/linux-x86-low.c -+++ b/gdb/gdbserver/linux-x86-low.c -@@ -338,6 +338,19 @@ x86_fill_gregset (struct regcache *regcache, void *buf) - - collect_register_by_name (regcache, "orig_eax", - ((char *) buf) + ORIG_EAX * REGSIZE); -+ -+ /* Sign extend EAX value to avoid potential syscall restart -+ problems. -+ -+ See amd64_linux_collect_native_gregset() in gdb/amd64-linux-nat.c -+ for a detailed explanation. */ -+ if (register_size (regcache->tdesc, 0) == 4) -+ { -+ void *ptr = ((gdb_byte *) buf -+ + i386_regmap[find_regno (regcache->tdesc, "eax")]); -+ -+ *(int64_t *) ptr = *(int32_t *) ptr; -+ } - } - - static void diff --git a/gdb.changes b/gdb.changes index 9e17c8c..bd2398b 100644 --- a/gdb.changes +++ b/gdb.changes @@ -1,3 +1,54 @@ +------------------------------------------------------------------- +Mon Sep 30 10:34:54 UTC 2019 - Tom de Vries + +- Add gdb-testsuite-8.3-kfail-xfail-unsupported.patch + +------------------------------------------------------------------- +Thu Sep 26 16:51:17 UTC 2019 - Tom de Vries + +- Drop ChangeLog part of patch: + * gdb-rhbz1708192-parse_macro_definition-crash.patch + * gdb-rhbz1704406-disable-style-log-output-1of3.patch + * gdb-rhbz1704406-disable-style-log-output-2of3.patch + * gdb-rhbz1704406-disable-style-log-output-3of3.patch + * gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch + * gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.patch +- Update to gdb-8.3.1. + * Drop "Testsuite: Ensure pie is disabled on some tests" part of + gdb-testsuite-pie-no-pie.patch + * Drop patches included upstream: + - gdb-7.10-swo18929.patch + - gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch + - gdb-x86_64-i386-syscall-restart-master.patch + - gdb-suppress-sigttou-when-handling-errors.patch + - gdb-fix-breakpoints-on-file-reloads-for-pie-binaries.patch + - gdb-symtab-fix-symbol-loading-performance-regression.patch +- Fix macro in comment warning + +------------------------------------------------------------------- +Wed Sep 25 14:41:32 UTC 2019 - Tom de Vries + +- Upgrade libipt from v2.0 to v2.0.1. + * Use -DBUILD_SHARED_LIBS=OFF to build libipt.a, and drop part + of v1.5-libipt-static.patch that consequentially has become + unnecessary. + +------------------------------------------------------------------- +Tue Sep 24 08:31:04 UTC 2019 - Tom de Vries + +- Sync with f30, merging 1e222a3..8bf40c6. + * gdb-rhbz1708192-parse_macro_definition-crash.patch + * gdb-rhbz1704406-disable-style-log-output-1of3.patch + * gdb-rhbz1704406-disable-style-log-output-2of3.patch + * gdb-rhbz1704406-disable-style-log-output-3of3.patch + * gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch + * gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.patch + +------------------------------------------------------------------- +Sun Sep 22 05:54:09 UTC 2019 - Tom de Vries + +- Use ldd /usr/bin/rpm instead of ls /usr/%{_lib}/ to find librpm + ------------------------------------------------------------------- Sat Sep 14 05:45:30 UTC 2019 - Michel Normand diff --git a/gdb.spec b/gdb.spec index 2f7e54f..44a389b 100644 --- a/gdb.spec +++ b/gdb.spec @@ -13,7 +13,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.opensuse.org/ # @@ -28,7 +28,7 @@ License: GPL-3.0-or-later AND GPL-3.0-with-GCC-exception AND LGPL-2.1-or- Group: Development/Tools/Debuggers Name: gdb -Version: 8.3 +Version: 8.3.1 Release: 0 # The release always contains a leading reserved number, start it at 1. @@ -87,7 +87,7 @@ Source4: gdbinit Source5: gdbinit.without-python # libipt: Intel Processor Trace Decoder Library -%global libipt_version 2.0 +%global libipt_version 2.0.1 Source7: v%{libipt_version}.tar.gz # Infrastructure to sync patches from the Fedora rpm @@ -211,6 +211,12 @@ Patch112: gdb-vla-intel-fix-print-char-array.patch Patch113: gdb-rhbz1553104-s390x-arch12-test.patch Patch114: gdb-rhbz795424-bitpos-arrayview.patch Patch115: gdb-rhbz1371380-gcore-elf-headers.patch +Patch116: gdb-rhbz1708192-parse_macro_definition-crash.patch +Patch117: gdb-rhbz1704406-disable-style-log-output-1of3.patch +Patch118: gdb-rhbz1704406-disable-style-log-output-2of3.patch +Patch119: gdb-rhbz1704406-disable-style-log-output-3of3.patch +Patch120: gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch +Patch121: gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.patch #Fedora Packages end #Fedora patches fixup @@ -226,30 +232,21 @@ Patch1003: gdb-testsuite-ada-pie.patch # Patches to upstream -# Fixed upstream Wed, 29 May 2019, 4330d61dfb "Fix crash in -# cp_print_value_fields". We should be able to drop this in 8.4. -Patch1005: gdb-7.10-swo18929.patch - # Fixed upstream Sat, Jun 22 2019, 47e3f47487 "[gdb] Fix s390x -m31 build". # We should be able to drop this in 8.4. Patch1007: gdb-fix-s390-build.diff # Backports from master -Patch2000: gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch Patch2001: gdb-fix-riscv-tdep.patch -Patch2002: gdb-x86_64-i386-syscall-restart-master.patch -Patch2003: gdb-suppress-sigttou-when-handling-errors.patch Patch2004: gdb-testsuite-add-missing-initial-prompt-read-in-multidictionary.exp.patch Patch2005: gdb-testsuite-pie-no-pie.patch -Patch2006: gdb-fix-breakpoints-on-file-reloads-for-pie-binaries.patch Patch2007: gdb-testsuite-read1-fixes.patch Patch2008: gdb-testsuite-i386-pkru-exp.patch - -# Submitted for master - Patch2500: gdb-fix-heap-use-after-free-in-typename-concat.patch -Patch2501: gdb-symtab-fix-symbol-loading-performance-regression.patch + +# Testsuite patches +Patch2600: gdb-testsuite-8.3-kfail-xfail-unsupported.patch # libipt support Patch3000: v1.5-libipt-static.patch @@ -566,6 +563,12 @@ find -name "*.info*"|xargs rm -f %patch113 -p1 %patch114 -p1 %patch115 -p1 +%patch116 -p1 +%patch117 -p1 +%patch118 -p1 +%patch119 -p1 +%patch120 -p1 +%patch121 -p1 #Fedora patching end %patch500 -p1 @@ -575,21 +578,17 @@ find -name "*.info*"|xargs rm -f %patch1002 -p1 %patch1003 -p1 -%patch1005 -p1 %patch1007 -p1 -%patch2000 -p1 %patch2001 -p1 -%patch2002 -p1 -%patch2003 -p1 %patch2004 -p1 %patch2005 -p1 -%patch2006 -p1 %patch2007 -p1 %patch2008 -p1 %patch2500 -p1 -%patch2501 -p1 + +%patch2600 -p1 #unpack libipt %if 0%{have_libipt} @@ -655,6 +654,7 @@ CFLAGS="$CFLAGS -DPERF_ATTR_SIZE_VER5_BUNDLE" cd processor-trace-%{libipt_version}-build # -DPTUNIT:BOOL=ON has no effect on ctest. cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DBUILD_SHARED_LIBS=OFF \ -DPTUNIT:BOOL=OFF \ -DDEVBUILD:BOOL=ON \ ../../processor-trace-%{libipt_version} @@ -669,12 +669,10 @@ LDFLAGS="$LDFLAGS -L$PWD/processor-trace-%{libipt_version}-root%{_libdir}" export CXXFLAGS="$CFLAGS" -export LIBRPM=$(ls -1 /usr/%{_lib}/ \ - | grep '^librpm.so.[0-9][0-9]*$' \ - | sort -V -r \ - | head -n 1) +export LIBRPM=$(ldd /bin/rpm \ + | grep librpm.so \ + | awk '{print $3}') if [ "$LIBRPM" != "" ]; then - export LIBRPM="/usr/%{_lib}/$LIBRPM" [ -f "$LIBRPM" ] else export LIBRPM=no @@ -821,7 +819,7 @@ then fi # This is a build-time test, but still a test. So, skip if we don't do tests. -# This is relevant for %qemu_user_space_build == 1 builds, which atm is +# This is relevant for %%qemu_user_space_build == 1 builds, which atm is # the case for riscv64. %if %{with testsuite} if [ "$LIBRPM" != "no" ]; then diff --git a/v1.5-libipt-static.patch b/v1.5-libipt-static.patch index 6a0ea82..6a0e9c4 100644 --- a/v1.5-libipt-static.patch +++ b/v1.5-libipt-static.patch @@ -1,14 +1,3 @@ ---- processor-trace-1.5/libipt/CMakeLists.txt-orig 2016-04-07 08:52:14.000000000 +0200 -+++ processor-trace-1.5/libipt/CMakeLists.txt 2016-08-17 23:12:23.241109244 +0200 -@@ -81,7 +81,7 @@ endif (CMAKE_HOST_WIN32) - - set(LIBIPT_FILES ${LIBIPT_FILES} ${LIBIPT_SECTION_FILES}) - --add_library(libipt SHARED -+add_library(libipt STATIC - ${LIBIPT_FILES} - ) - --- processor-trace-1.5/libipt/src/posix/init.c-orig 2016-04-07 08:52:14.000000000 +0200 +++ processor-trace-1.5/libipt/src/posix/init.c 2016-08-23 09:04:11.540176668 +0200 @@ -29,7 +29,7 @@ diff --git a/v2.0.1.tar.gz b/v2.0.1.tar.gz new file mode 100644 index 0000000..611e1eb --- /dev/null +++ b/v2.0.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:541e0cc969144ce64bcfced40fa21b08b77277d2420cffe2e86f1497f39e0e5c +size 355385 diff --git a/v2.0.tar.gz b/v2.0.tar.gz deleted file mode 100644 index f4780c1..0000000 --- a/v2.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:668aed61eb20cda87e26e87f5a72d75260052ab498fe6447109cdd18dc8afaad -size 338965