Hello community, here is the log from the commit of package gdb for openSUSE:Factory checked in at 2019-10-05 16:18:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/gdb (Old) and /work/SRC/openSUSE:Factory/.gdb.new.2352 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "gdb" Sat Oct 5 16:18:05 2019 rev:131 rq:734351 version:8.3.1 Changes: -------- --- /work/SRC/openSUSE:Factory/gdb/gdb.changes 2019-09-19 15:51:14.735288380 +0200 +++ /work/SRC/openSUSE:Factory/.gdb.new.2352/gdb.changes 2019-10-05 16:19:07.341622030 +0200 @@ -1,0 +2,51 @@ +Mon Sep 30 10:34:54 UTC 2019 - Tom de Vries <[email protected]> + +- Add gdb-testsuite-8.3-kfail-xfail-unsupported.patch + +------------------------------------------------------------------- +Thu Sep 26 16:51:17 UTC 2019 - Tom de Vries <[email protected]> + +- 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 <[email protected]> + +- 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 <[email protected]> + +- 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 <[email protected]> + +- Use ldd /usr/bin/rpm instead of ls /usr/%{_lib}/ to find librpm + +------------------------------------------------------------------- Old: ---- gdb-7.10-swo18929.patch gdb-8.3.tar.bz2 gdb-fix-breakpoints-on-file-reloads-for-pie-binaries.patch gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch gdb-suppress-sigttou-when-handling-errors.patch gdb-symtab-fix-symbol-loading-performance-regression.patch gdb-x86_64-i386-syscall-restart-master.patch v2.0.tar.gz New: ---- gdb-8.3.1.tar.bz2 gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.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-rhbz1708192-parse_macro_definition-crash.patch gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch gdb-testsuite-8.3-kfail-xfail-unsupported.patch v2.0.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gdb.spec ++++++ --- /var/tmp/diff_new_pack.jrrQZq/_old 2019-10-05 16:19:12.313609084 +0200 +++ /var/tmp/diff_new_pack.jrrQZq/_new 2019-10-05 16:19:12.321609063 +0200 @@ -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 @@ 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 @@ 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 @@ 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 @@ # 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 @@ %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 @@ %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 @@ 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 @@ 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 @@ 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 ++++++ gdb-8.3.tar.bz2 -> gdb-8.3.1.tar.bz2 ++++++ /work/SRC/openSUSE:Factory/gdb/gdb-8.3.tar.bz2 /work/SRC/openSUSE:Factory/.gdb.new.2352/gdb-8.3.1.tar.bz2 differ: char 11, line 1 ++++++ gdb-rhbz1553086-binutils-warning-loadable-section-outside-elf.patch ++++++ >From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Nick Clifton <[email protected]> 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"), ++++++ gdb-rhbz1704406-disable-style-log-output-1of3.patch ++++++ >From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Tom Tromey <[email protected]> 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 <[email protected]> * 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" +} ++++++ gdb-rhbz1704406-disable-style-log-output-2of3.patch ++++++ >From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Tom Tromey <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 <http://www.gnu.org/licenses/>. + +# 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); ++++++ gdb-rhbz1704406-disable-style-log-output-3of3.patch ++++++ >From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Andrew Burgess <[email protected]> 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 .*" ++++++ gdb-rhbz1708192-parse_macro_definition-crash.patch ++++++ >From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior <[email protected]> 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 <[email protected]> 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 { ++++++ gdb-rhbz1723564-gdb-crash-PYTHONMALLOC-debug.patch ++++++ >From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior <[email protected]> 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 <[email protected]> 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"); ++++++ gdb-testsuite-8.3-kfail-xfail-unsupported.patch ++++++ ++++ 948 lines (skipped) ++++++ gdb-testsuite-pie-no-pie.patch ++++++ --- /var/tmp/diff_new_pack.jrrQZq/_old 2019-10-05 16:19:12.705608063 +0200 +++ /var/tmp/diff_new_pack.jrrQZq/_new 2019-10-05 16:19:12.705608063 +0200 @@ -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 @@ --------------------------------------------------------- -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 ++++++ v1.5-libipt-static.patch ++++++ --- /var/tmp/diff_new_pack.jrrQZq/_old 2019-10-05 16:19:12.769607897 +0200 +++ /var/tmp/diff_new_pack.jrrQZq/_new 2019-10-05 16:19:12.769607897 +0200 @@ -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 @@ ++++++ v2.0.tar.gz -> v2.0.1.tar.gz ++++++ ++++ 4450 lines of diff (skipped)
