From b2d009af0ce496ba42fd2f24eefeebff8a133305 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 22 Apr 2007 13:13:52 +0000 Subject: [PATCH] - Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517). - Fix testcase for watchpoints in threads (for BZ 237096). - BuildRequires now `libunwind-devel' instead of the former `libunwind'. - Use the runtime libunwind .so.7, it requires now >= 0.99-0.1.frysk20070405cvs. - Resolves: rhbz#229517 - Related: rhbz#237096 --- gdb-6.6-bz229517-gcore-without-terminal.patch | 191 ++++++++++++++++++ ....6-bz237096-watchthreads-testcasefix.patch | 62 ++++++ gdb-6.6-libunwind-major-version.patch | 13 ++ gdb.spec | 44 +++- 4 files changed, 300 insertions(+), 10 deletions(-) create mode 100644 gdb-6.6-bz229517-gcore-without-terminal.patch create mode 100644 gdb-6.6-bz237096-watchthreads-testcasefix.patch create mode 100644 gdb-6.6-libunwind-major-version.patch diff --git a/gdb-6.6-bz229517-gcore-without-terminal.patch b/gdb-6.6-bz229517-gcore-without-terminal.patch new file mode 100644 index 0000000..de34ed5 --- /dev/null +++ b/gdb-6.6-bz229517-gcore-without-terminal.patch @@ -0,0 +1,191 @@ +2007-04-22 Jan Kratochvil + + * gdb_gcore.sh: Redirect GDB from ` + + * gdb.base/gcorebg.exp, gdb.base/gcorebg.c: New files. + + +--- gdb-6.6-orig/gdb/gdb_gcore.sh 2005-12-17 17:33:59.000000000 -0500 ++++ gdb-6.6/gdb/gdb_gcore.sh 2007-04-22 05:42:50.000000000 -0400 +@@ -71,7 +71,9 @@ + quit + EOF + +- gdb -x $tmpfile -batch ++ # ` ++#include ++#include ++#include ++#include ++ ++int main (int argc, char **argv) ++{ ++ pid_t pid = 0; ++ pid_t ppid; ++ char buf[256]; ++ ++ if (argc != 4) ++ { ++ fprintf (stderr, "Syntax: %s {standard|detached} \n", ++ argv[0]); ++ exit (1); ++ } ++ ++ pid = fork (); ++ ++ switch (pid) ++ { ++ case 0: ++ if (strcmp (argv[1], "detached") == 0) ++ setpgrp (); ++ ppid = getppid (); ++ sprintf (buf, "sh %s -o %s %d", argv[2], argv[3], (int) ppid); ++ system (buf); ++ kill (ppid, SIGTERM); ++ break; ++ ++ case -1: ++ perror ("fork err\n"); ++ exit (1); ++ break; ++ ++ default: ++ sleep (60); ++ } ++ ++ return 0; ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/gcorebg.exp 25 Feb 2007 12:21:20 -0000 +@@ -0,0 +1,120 @@ ++# Copyright 2007 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# Please email any bugs, comments, and/or additions to this file to: ++# bug-gdb@prep.ai.mit.edu ++ ++# This file was written by Jan Kratochvil . ++# This is a test for `gdb_gcore.sh' functionality. ++# It also tests a regression with `gdb_gcore.sh' being run without its ++# accessible terminal. ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set prms_id 0 ++set bug_id 0 ++ ++if ![info exists GCORE] { ++ set GCORE "${srcdir}/../gdb_gcore.sh" ++} ++verbose "using GCORE = $GCORE" 2 ++ ++set testfile "gcorebg" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set corefile ${objdir}/${subdir}/${testfile}.test ++ ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ untested gcorebg.exp ++ return -1 ++} ++ ++# Cleanup. ++ ++proc core_clean {} { ++ global corefile ++ ++ foreach file [glob -nocomplain [join [list $corefile *] ""]] { ++ verbose "Delete file $file" 1 ++ remote_file target delete $file ++ } ++} ++core_clean ++remote_file target delete "./gdb" ++ ++# Generate the core file. ++ ++# Provide `./gdb' for `gdb_gcore.sh' running it as a bare `gdb' command. ++# Setup also `$PATH' appropriately. ++# If GDB was not found let `gdb_gcore.sh' to find the system GDB by `$PATH'. ++if {$GDB != "gdb"} { ++ file link ./gdb $GDB ++} ++global env ++set oldpath $env(PATH) ++set env(PATH) [join [list . $env(PATH)] ":"] ++verbose "PATH = $env(PATH)" 2 ++ ++# Test file body. ++# $detached == "standard" || $detached == "detached" ++ ++proc test_body { detached } { ++ global binfile ++ global GCORE ++ global corefile ++ ++ set res [remote_spawn target "$binfile $detached $GCORE $corefile"] ++ if { $res < 0 || $res == "" } { ++ fail "Spawning $detached gcore" ++ return 1 ++ } ++ pass "Spawning $detached gcore" ++ remote_expect target 20 { ++ timeout { ++ fail "Spawned $detached gcore finished" ++ remote_exec target "kill -9 -[exp_pid -i $res]" ++ return 1 ++ } ++ eof { ++ pass "Spawned $detached gcore finished" ++ remote_wait target 20 ++ } ++ } ++ ++ if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} { ++ pass "Core file generated by $detached gcore" ++ } else { ++ fail "Core file generated by $detached gcore" ++ } ++ core_clean ++} ++ ++# First a general `gdb_gcore.sh' spawn with its controlling terminal available. ++ ++test_body standard ++ ++# And now `gdb_gcore.sh' spawn without its controlling terminal available. ++# It is spawned through `gcorebg.c' using setpgrp (). ++ ++test_body detached ++ ++ ++# Cleanup. ++ ++set env(PATH) $oldpath ++remote_file target delete "./gdb" diff --git a/gdb-6.6-bz237096-watchthreads-testcasefix.patch b/gdb-6.6-bz237096-watchthreads-testcasefix.patch new file mode 100644 index 0000000..ca86ad5 --- /dev/null +++ b/gdb-6.6-bz237096-watchthreads-testcasefix.patch @@ -0,0 +1,62 @@ +TODO: ./gdb/testsuite/gdb.threads/watchthreads2.exp + +It applies only to recent (~2.6.20) Linux kernels, on RHEL4 the behavior is not +changed (and this patch has no effect there). + + +--- ./gdb/testsuite/gdb.threads/watchthreads.exp 9 Jan 2007 17:59:14 -0000 1.3 ++++ ./gdb/testsuite/gdb.threads/watchthreads.exp 20 Apr 2007 19:11:01 -0000 +@@ -65,25 +65,42 @@ set inc_line [gdb_get_line_number "Loop + + # Loop and continue to allow both watchpoints to be triggered. + for {set i 0} {$i < 30} {incr i} { +- set test_flag 0 ++ set test_flag_0 0 ++ set test_flag_1 0 + gdb_test_multiple "continue" "threaded watch loop" { +- -re "Hardware watchpoint 2: args\\\[0\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads.c:$init_line.*$gdb_prompt $" +- { set args_0 1; set test_flag 1 } +- -re "Hardware watchpoint 3: args\\\[1\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads.c:$init_line.*$gdb_prompt $" +- { set args_1 1; set test_flag 1 } +- -re "Hardware watchpoint 2: args\\\[0\\\].*Old value = $args_0.*New value = [expr $args_0+1].*in thread_function \\\(arg=0x0\\\) at .*watchthreads.c:$inc_line.*$gdb_prompt $" +- { set args_0 [expr $args_0+1]; set test_flag 1 } +- -re "Hardware watchpoint 3: args\\\[1\\\].*Old value = $args_1.*New value = [expr $args_1+1].*in thread_function \\\(arg=0x1\\\) at .*watchthreads.c:$inc_line.*$gdb_prompt $" +- { set args_1 [expr $args_1+1]; set test_flag 1 } ++ -re "(.*)$gdb_prompt $" { ++ set test_flag_1 1 ++ set string $expect_out(1,string) ++ foreach match [regexp -nocase -all -inline "Hardware watchpoint .*? at .*?watchthreads.c:\[0-9\]*\r" $string] { ++ # FIXME: Test also for the trailing: \[^\r\]*main \\\(\\\) at .*?watchthreads.c:$init_line\r ++ # We cannot test the line position as we do not get it for the ++ # non-active threads (not being last in the list). ++ if [regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = 0\[^\r\]*\r\[^\r\]*New value = 1\r" $match] { ++ set args_0 1; set test_flag_0 1 ++ } ++ # FIXME: Test also for the trailing: \[^\r\]*main \\\(\\\) at .*?watchthreads.c:$init_line\r ++ if [regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = 0\[^\r\]*\r\[^\r\]*New value = 1\r" $match] { ++ set args_1 1; set test_flag_0 1 ++ } ++ # FIXME: Test also for the trailing: \[^\r\]*thread_function \\\(arg=0x0\\\) at .*?watchthreads.c:$inc_line\r ++ if [regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_0\[^\r\]*\r\[^\r\]*New value = [expr $args_0+1]\r" $match] { ++ set args_0 [expr $args_0+1]; set test_flag_0 1 ++ } ++ # FIXME: Test also for the trailing: \[^\r\]*thread_function \\\(arg=0x0\\\) at .*?watchthreads.c:$inc_line\r ++ if [regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_1\[^\r\]*\r\[^\r\]*New value = [expr $args_1+1]\r" $match] { ++ set args_1 [expr $args_1+1]; set test_flag_0 1 ++ } ++ } ++ } + } + # If we fail above, don't bother continuing loop +- if { $test_flag == 0 } { ++ if { $test_flag_0 == 0 || $test_flag_1 == 0 } { + set i 30; + } + } + + # Print success message if loop succeeded. +-if { $test_flag == 1 } { ++if { $test_flag_0 == 1 && $test_flag_1 == 1 } { + pass "threaded watch loop" + } + diff --git a/gdb-6.6-libunwind-major-version.patch b/gdb-6.6-libunwind-major-version.patch new file mode 100644 index 0000000..f98ab8d --- /dev/null +++ b/gdb-6.6-libunwind-major-version.patch @@ -0,0 +1,13 @@ +--- gdb-6.6-orig/gdb/libunwind-frame.c 2007-04-08 20:49:09.000000000 +0200 ++++ gdb-6.6/gdb/libunwind-frame.c 2007-04-10 23:45:22.000000000 +0200 +@@ -74,7 +74,9 @@ + #define STRINGIFY(name) STRINGIFY2(name) + + #ifndef LIBUNWIND_SO +-#define LIBUNWIND_SO "libunwind-" STRINGIFY(UNW_TARGET) ".so" ++/* Use the stable ABI major version number. `libunwind-ia64.so' is a link time ++ only library, not a runtime one. */ ++#define LIBUNWIND_SO "libunwind-" STRINGIFY(UNW_TARGET) ".so.7" + #endif + + static char *get_reg_name = STRINGIFY(UNW_OBJ(get_reg)); diff --git a/gdb.spec b/gdb.spec index 5b4178a..36376f9 100644 --- a/gdb.spec +++ b/gdb.spec @@ -11,7 +11,7 @@ Name: gdb Version: 6.6 # The release always contains a leading reserved number, start it at 1. -Release: 8%{?dist} +Release: 9%{?dist} License: GPL Group: Development/Debuggers @@ -317,6 +317,15 @@ Patch236: gdb-6.6-bz232371-selinux-thread-error.patch # Use definition of an empty structure as it is not an opaque type (BZ 233716). Patch238: gdb-6.6-bz233716-empty-structure-override.patch +# Use the runtime variant of `libunwind-ARCH.so.7' rather than the `.so' one. +Patch244: gdb-6.6-libunwind-major-version.patch + +# Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517). +Patch245: gdb-6.6-bz229517-gcore-without-terminal.patch + +# Fix testcase for watchpoints in threads (for BZ 237096). +Patch246: gdb-6.6-bz237096-watchthreads-testcasefix.patch + BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext BuildRequires: flex bison sharutils @@ -327,8 +336,8 @@ BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc. %endif %ifarch ia64 -BuildRequires: libunwind >= 0.96-3 -Requires: libunwind >= 0.96-3 +BuildRequires: libunwind-devel >= 0.99-0.1.frysk20070405cvs +Requires: libunwind >= 0.99-0.1.frysk20070405cvs %else BuildRequires: prelink %endif @@ -445,6 +454,9 @@ and printing their data. %patch235 -p1 %patch236 -p1 %patch238 -p1 +%patch244 -p1 +%patch245 -p1 +%patch246 -p1 # Change the version that gets printed at GDB startup, so it is RedHat # specific. @@ -483,13 +495,19 @@ enable_build_warnings="" enable_build_warnings="--enable-gdb-build-warnings=,-Werror" %endif -../configure \ - --prefix=%{_prefix} \ - --sysconfdir=%{_sysconfdir} \ - --mandir=%{_mandir} \ - --infodir=%{_infodir}\ - $enable_build_warnings \ - --with-separate-debug-dir=/usr/lib/debug \ +../configure \ + --prefix=%{_prefix} \ + --libdir=%{_libdir} \ + --sysconfdir=%{_sysconfdir} \ + --mandir=%{_mandir} \ + --infodir=%{_infodir} \ + $enable_build_warnings \ + --with-separate-debug-dir=/usr/lib/debug \ +%ifarch ia64 + --with-libunwind \ +%else + --without-libunwind \ +%endif %{_target_platform} make -k @@ -607,6 +625,12 @@ fi # don't include the files in include, they are part of binutils %changelog +* Sun Apr 22 2007 Jan Kratochvil - 6.6-9 +- Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517). +- Fix testcase for watchpoints in threads (for BZ 237096). +- BuildRequires now `libunwind-devel' instead of the former `libunwind'. +- Use the runtime libunwind .so.7, it requires now >= 0.99-0.1.frysk20070405cvs. + * Sat Mar 24 2007 Jan Kratochvil - 6.6-8 - Use definition of an empty structure as it is not an opaque type (BZ 233716). - Fixed the gdb.base/attachstop.exp testcase false 2 FAILs.