rpms/gdb/FC-6 gdb-6.5-BEA-testsuite.patch, NONE, 1.1 gdb-6.5-last-address-space-byte-test.patch, NONE, 1.1 gdb-6.5-matching_bfd_sections.patch, NONE, 1.1 gdb-6.5-readline-long-line-crash.patch, NONE, 1.1 gdb-6.5-relativedebug.patch, NONE, 1.1 gdb-6.5-symbols-overlap.patch, NONE, 1.1 gdb-orphanripper.c, NONE, 1.1 gdb.spec, 1.202, 1.203

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Dec 11 21:45:40 UTC 2006


Author: jkratoch

Update of /cvs/dist/rpms/gdb/FC-6
In directory cvs.devel.redhat.com:/tmp/cvs-serv14532

Modified Files:
	gdb.spec 
Added Files:
	gdb-6.5-BEA-testsuite.patch 
	gdb-6.5-last-address-space-byte-test.patch 
	gdb-6.5-matching_bfd_sections.patch 
	gdb-6.5-readline-long-line-crash.patch 
	gdb-6.5-relativedebug.patch gdb-6.5-symbols-overlap.patch 
	gdb-orphanripper.c 
Log Message:
* Mon Dec 11 2006 Jan Kratochvil <jan.kratochvil at redhat.com> - 6.5-14
- Fix "??" resolving of symbols from (non-prelinked) debuginfo packages.
- Fix "??" resolving of symbols from overlapping functions (nanosleep(3)).
- Also disable testcase "checkpoint.exp" for a possible kernel Bug 207002.
- Provided (disabled during build) threading testsuite from BEA.
- Fix readline segfault on excessively long hand-typed lines.
- Provide testcase for accessing the last address space byte.
- Cleanup any leftover testsuite processes as it may stuck mock(1) builds.
- Related: rhbz#207002


gdb-6.5-BEA-testsuite.patch:
 threadcrash.c       |  301 ++++++++++++++++++++++++++++++++++++++++++++++++
 threadcrash.exp     |   37 +++++
 threadcrash.sh      |  324 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 threadcrash.sh-orig |  248 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 910 insertions(+)

--- NEW FILE gdb-6.5-BEA-testsuite.patch ---
Index: ./gdb/testsuite/gdb.threads/threadcrash.c
===================================================================
RCS file: gdb/testsuite/gdb.threads/threadcrash.c
diff -N gdb/testsuite/gdb.threads/threadcrash.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.threads/threadcrash.c	31 Oct 2006 17:54:38 -0000
@@ -0,0 +1,301 @@
+/*
+ * The point of this program is to crash in a multi-threaded app.
+ * There are seven threads, doing the following things:
+ * * Spinning
+ * * Spinning inside a signal handler
+ * * Spinning inside a signal handler executing on the altstack
+ * * In a syscall
+ * * In a syscall inside a signal handler
+ * * In a syscall inside a signal handler executing on the altstack
+ * * Finally, the main thread crashes in main, with no frills.
+ *
+ * These are the things threads in JRockit tend to be doing.  If gdb
+ * can handle those things, both in core files and during live
+ * debugging, that will help (at least) JRockit development.
+ *
+ * Let the program create a core file, then load the core file into
+ * gdb.  Inside gdb, you should be able to do something like this:
+ *
+ * (gdb) t a a bt
+ * 
+ * Thread 7 (process 4352):
+ * #0  0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6
+ * #1  0x001ba5ff in sleep () from /lib/tls/libc.so.6
+ * #2  0x080488a2 in makeSyscall (ignored=0x0) at threadcrash.c:118
+ * #3  0x006aadec in start_thread () from /lib/tls/libpthread.so.0
+ * #4  0x001ed19a in clone () from /lib/tls/libc.so.6
+ * 
+ * Thread 6 (process 4353):
+ * #0  0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6
+ * #1  0x001ba5ff in sleep () from /lib/tls/libc.so.6
+ * #2  0x0804898f in syscallingSighandler (signo=10, info=0xb6be76f0, context=0xb6be7770)
+ *     at threadcrash.c:168
+ * #3  <signal handler called>
+ * #4  0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
+ * #5  0x08048a51 in makeSyscallFromSighandler (ignored=0x0) at threadcrash.c:204
+ * #6  0x006aadec in start_thread () from /lib/tls/libpthread.so.0
+ * #7  0x001ed19a in clone () from /lib/tls/libc.so.6
+ * 
+ * Thread 5 (process 4354):
+ * #0  0x001ba7dc in __nanosleep_nocancel () from /lib/tls/libc.so.6
+ * #1  0x001ba5ff in sleep () from /lib/tls/libc.so.6
+ * #2  0x08048936 in syscallingAltSighandler (signo=3, info=0x959cd70, context=0x959cdf0)
+ *     at threadcrash.c:144
+ * #3  <signal handler called>
+ * #4  0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
+ * #5  0x080489e2 in makeSyscallFromAltSighandler (ignored=0x0) at threadcrash.c:190
+ * #6  0x006aadec in start_thread () from /lib/tls/libpthread.so.0
+ * #7  0x001ed19a in clone () from /lib/tls/libc.so.6
+ * 
+ * Thread 4 (process 4355):
+ * #0  spin (ignored=0x0) at threadcrash.c:242
+ * #1  0x006aadec in start_thread () from /lib/tls/libpthread.so.0
+ * #2  0x001ed19a in clone () from /lib/tls/libc.so.6
+ * 
+ * Thread 3 (process 4356):
+ * #0  spinningSighandler (signo=12, info=0xb4de46f0, context=0xb4de4770) at threadcrash.c:180
+ * #1  <signal handler called>
+ * #2  0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
+ * #3  0x08048b2f in spinFromSighandler (ignored=0x0) at threadcrash.c:232
+ * #4  0x006aadec in start_thread () from /lib/tls/libpthread.so.0
+ * #5  0x001ed19a in clone () from /lib/tls/libc.so.6
+ * 
+ * Thread 2 (process 4357):
+ * #0  spinningAltSighandler (signo=14, info=0x959ee50, context=0x959eed0) at threadcrash.c:156
+ * #1  <signal handler called>
+ * #2  0x006adf5e in pthread_kill () from /lib/tls/libpthread.so.0
+ * #3  0x08048ac0 in spinFromAltSighandler (ignored=0x0) at threadcrash.c:218
+ * #4  0x006aadec in start_thread () from /lib/tls/libpthread.so.0
+ * #5  0x001ed19a in clone () from /lib/tls/libc.so.6
+ * 
+ * Thread 1 (process 4351):
+ * #0  0x08048cf3 in main (argc=1, argv=0xbfff9d74) at threadcrash.c:273
+ * (gdb)
+ */
+
+#include <pthread.h>
+#include <signal.h>
+#include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define SIGSYSCALL_ALT SIGQUIT
+#define SIGSYSCALL SIGUSR1
+#define SIGSPIN_ALT SIGALRM
+#define SIGSPIN SIGUSR2
+
+typedef void (*sigaction_t)(int, siginfo_t *, void *);
+
+static void installHandler(int signo, sigaction_t handler, int onAltstack) {
+   struct sigaction action;
+   sigset_t sigset;
+   int result;
+   stack_t altstack;
+   stack_t oldaltstack;
+   
+   memset(&action, 0, sizeof(action));
+   memset(&altstack, 0, sizeof(altstack));
+   memset(&oldaltstack, 0, sizeof(oldaltstack));
+   
+   if (onAltstack) {
+      altstack.ss_sp = malloc(SIGSTKSZ);
+      assert(altstack.ss_sp != NULL);
+      altstack.ss_size = SIGSTKSZ;
+      altstack.ss_flags = 0;
+      result = sigaltstack(&altstack, &oldaltstack);
+      assert(result == 0);
+      assert(oldaltstack.ss_flags == SS_DISABLE);
+   }
+   
+   sigemptyset(&sigset);
+   
+   action.sa_handler = NULL;
+   action.sa_sigaction = handler;
+   action.sa_mask = sigset;
+   action.sa_flags = SA_SIGINFO;
+   if (onAltstack) {
+      action.sa_flags |= SA_ONSTACK;
+   }
+   
+   result = sigaction(signo, &action, NULL);
+   assert(result == 0);
+}
+
+static void installNormalHandler(int signo, sigaction_t handler) {
+   installHandler(signo, handler, 0);
+}
+
+static void installAlthandler(int signo, sigaction_t handler) {
+   installHandler(signo, handler, 1);
+}
+
+static void *makeSyscall(void *ignored) {
+   (void)ignored;
+
+   sleep(42);
+
+   fprintf(stderr, "%s: returning\n", __FUNCTION__);
+   return NULL;
+}
+
+/* Return true if we're currently executing on the altstack */
+static int onAltstack(void) {
+   stack_t stack;
+   int result;
+   
+   result = sigaltstack(NULL, &stack);
+   assert(result == 0);
+   
+   return stack.ss_flags & SS_ONSTACK;
+}
+
+static void syscallingAltSighandler(int signo, siginfo_t *info, void *context) {
+   (void)signo;
+   (void)info;
+   (void)context;
+   
+   if (!onAltstack()) {
+      printf("%s() not running on altstack!\n", __FUNCTION__);
+   }
+   
+   sleep(42);
+}
+
+static void spinningAltSighandler(int signo, siginfo_t *info, void *context) {
+   (void)signo;
+   (void)info;
+   (void)context;
+   
+   if (!onAltstack()) {
+      printf("%s() not running on altstack!\n", __FUNCTION__);
+   }
+   
+   while (1);
+}
+
+static void syscallingSighandler(int signo, siginfo_t *info, void *context) {
+   (void)signo;
+   (void)info;
+   (void)context;
+   
+   if (onAltstack()) {
+      printf("%s() running on altstack!\n", __FUNCTION__);
+   }
+   
+   sleep(42);
+}
+
+static void spinningSighandler(int signo, siginfo_t *info, void *context) {
+   (void)signo;
+   (void)info;
+   (void)context;
+   
+   if (onAltstack()) {
+      printf("%s() running on altstack!\n", __FUNCTION__);
+   }
+   
+   while (1);
+}
+
+static void *makeSyscallFromAltSighandler(void *ignored) {
+   (void)ignored;
+   
+   int result;
+   
+   installAlthandler(SIGSYSCALL_ALT, syscallingAltSighandler);
+   
+   result = pthread_kill(pthread_self(), SIGSYSCALL_ALT);
+   assert(result == 0);
+   
+   fprintf(stderr, "%s: returning\n", __FUNCTION__);
+   return NULL;
+}
+
+static void *makeSyscallFromSighandler(void *ignored) {
+   (void)ignored;
+   
+   int result;
+   
+   installNormalHandler(SIGSYSCALL, syscallingSighandler);
+   
+   result = pthread_kill(pthread_self(), SIGSYSCALL);
+   assert(result == 0);
+   
+   fprintf(stderr, "%s: returning\n", __FUNCTION__);
+   return NULL;
+}
+
+static void *spinFromAltSighandler(void *ignored) {
+   (void)ignored;
+   
+   int result;
+   
+   installAlthandler(SIGSPIN_ALT, spinningAltSighandler);
+   
+   result = pthread_kill(pthread_self(), SIGSPIN_ALT);
+   assert(result == 0);
+   
+   fprintf(stderr, "%s: returning\n", __FUNCTION__);
+   return NULL;
+}
+
+static void *spinFromSighandler(void *ignored) {
+   (void)ignored;
+   
+   int result;
+   
+   installNormalHandler(SIGSPIN, spinningSighandler);
+   
+   result = pthread_kill(pthread_self(), SIGSPIN);
+   assert(result == 0);
+   
+   fprintf(stderr, "%s: returning\n", __FUNCTION__);
+   return NULL;
+}
+
+static void *spin(void *ignored) {
+   (void)ignored;
+   
+   while (1);
+
+   fprintf(stderr, "%s: returning\n", __FUNCTION__);
+   return NULL;
+}
+
+int main(int argc, char *argv[]) {
+   int result;
+   pthread_t thread;
+   volatile int bad;
+   
+   result = pthread_create(&thread, NULL, makeSyscall, NULL);
+   assert(result == 0);
+   result = pthread_create(&thread, NULL, makeSyscallFromSighandler, NULL);
+   assert(result == 0);
+   result = pthread_create(&thread, NULL, makeSyscallFromAltSighandler, NULL);
+   assert(result == 0);
+   result = pthread_create(&thread, NULL, spin, NULL);
+   assert(result == 0);
+   result = pthread_create(&thread, NULL, spinFromSighandler, NULL);
+   assert(result == 0);
+   result = pthread_create(&thread, NULL, spinFromAltSighandler, NULL);
+   assert(result == 0);
+   
+   // Give threads some time to get going
+   sleep(3);
+   
+   // Crash
+   bad = *(int*)7;
+
+   /* Workaround: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29628
+      Simulate use to ensure `DW_AT_location' for them:
+      readelf -a --debug threadcrash|grep -A5 -w argc
+      --> DW_AT_location    : 2 byte block: 71 0     (DW_OP_breg1: 0)
+      This case verified on: gcc-4.1.1-30.i386
+      Keep it late to ensure persistency in the registers.  */
+   bad = (int) argc;
+   bad = (unsigned long) argv;
+   
+   return 0;
+}
Index: ./gdb/testsuite/gdb.threads/threadcrash.exp
===================================================================
RCS file: gdb/testsuite/gdb.threads/threadcrash.exp
diff -N gdb/testsuite/gdb.threads/threadcrash.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.threads/threadcrash.exp	31 Oct 2006 17:54:38 -0000
@@ -0,0 +1,37 @@
+# threadcrash.exp - The point of this program is to crash in a multi-threaded app.
+
+
+set testfile threadcrash
+set srcfile ${testfile}.c
+set shellfile ${srcdir}/${subdir}/${testfile}.sh
+set binfile ${objdir}/${subdir}/${testfile}
+
+set GDB_abs ${GDB}
+if [regexp "^\[^/\]" ${GDB_abs}] {
+    set GDB_abs $env(PWD)/${GDB_abs}
+}
+
+if [istarget "*-*-linux"] then {
+    set target_cflags "-D_MIT_POSIX_THREADS"
+} else {
+    set target_cflags ""
+}
+
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+    return -1
+}
+
+# ${shellfile} argument must not contain any directories.
+set fd [open "|bash ${shellfile} ${binfile} $GDB -nw $GDBFLAGS" r]
+while { [gets $fd line] >= 0 } {
+    if [regexp " PASS: (.*)$" $line trash message] {
+	pass $message
+    } elseif [regexp " FAIL: (.*)$" $line trash message] {
+	fail $message
+    }
+}
+catch {
+    close $fd
+}
+
+return 0
Index: ./gdb/testsuite/gdb.threads/threadcrash.sh
===================================================================
RCS file: gdb/testsuite/gdb.threads/threadcrash.sh
diff -N gdb/testsuite/gdb.threads/threadcrash.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.threads/threadcrash.sh	31 Oct 2006 17:54:38 -0000
@@ -0,0 +1,324 @@
+#! /bin/bash
+
+# NOTE: threadcrash.c *must* be built with debugging symbols
+#
+# The point of this shell script is to crash treadcrash.c, load the
+# resulting core file into gdb and verify that gdb can extract enough
+# information from the core file.
+#
+# The return code from this script is the number of failed tests.
+
+LOG=gdbresult.log
+
+if [ $# = 0 ] ; then
+    echo >&2 Syntax: $0 \<name of threadcrash binary\> [\<gdb binary\> \<args...\>]
+    exit 1
+fi
+RUNME="$1"
+shift
+GDB="${*:-gdb}"
+
+
+pf_prefix=""
+function pf_prefix() {
+	pf_prefix="$*"
+}
+
+set_test=""
+function set_test() {
+	if [ -n "$set_test" ] ; then
+		echo >&2 "DEJAGNU-BASH ERROR: set_test already set"
+		exit 1
+	fi
+	set_test="$*"
+	if [ -n "$pf_prefix" ] ; then
+		set_test="$pf_prefix: $set_test"
+	fi
+}
+
+# INTERNAL
+function record_test {
+	if [ -z "$set_test" ] ; then
+		echo >&2 "DEJAGNU-BASH ERROR: set_test not set"
+		exit 1
+	fi
+	# Provide the leading whitespace delimiter:
+	echo " $1: $set_test"
+	set_test=""
+}
+
+function pass() {
+	record_test PASS
+}
+function fail() {
+	record_test FAIL
+}
+
+
+# Verify that the gdb output doesn't contain $1.
+function mustNotHave() {
+    local BADWORD=$1
+    set_test gdb output contains "$BADWORD"
+    if grep -q "$BADWORD" $LOG ; then
+        fail
+        return 1
+    fi
+    pass
+    return 0
+}
+
+# Verify that the gdb output contains exactly $1 $2s.
+function mustHaveCorrectAmount() {
+    local WANTEDNUMBER=$1
+    local GOODWORD=$2
+    local ACTUALNUMBER=$(grep "$GOODWORD" $LOG | wc -l)
+    set_test gdb output contained $ACTUALNUMBER \""$GOODWORD"\", not $WANTEDNUMBER as expected
+    if [ $ACTUALNUMBER != $WANTEDNUMBER ] ; then
+        fail
+        return 1
+    fi
+    pass
+    return 0
+}
+
+# Verify that the gdb output contains seven threads
+function mustHaveSevenThreads() {
+    NTHREADS=$(egrep "^Thread [1-7] \(" $LOG | wc -l)
+    set_test gdb output contains $NTHREADS threads, not 7 as expected
+    if [ $NTHREADS != 7 ] ; then
+        fail
+        return 1
+    fi
+    pass
+    return 0
+}
+
+# Verify that the gdb output has all parameters on consecutive lines
+function mustHaveSequence() {
+    SEQUENCE="$*"
+    NPARTS=$#
+    grep "$1" -A$((NPARTS - 1)) $LOG > matches.log
+
+    while [ $# -gt 1 ] ; do
+        shift
+        ((NPARTS--))
+        grep "$1" -A$((NPARTS - 1)) matches.log > temp.log
+        mv temp.log matches.log
+    done
+    LASTPART=$1
+
+    set_test gdb output does not contain the sequence: $SEQUENCE
+    if ! grep -q "$LASTPART" matches.log ; then
+        fail
+        return 1
+    fi
+    pass
+    return 0
+}
+
+# Verify that $LOG contains all information we want
+function verifyLog() {
+    local FAILURES=0
+    
+    mustNotHave '??' || ((FAILURES++))
+    mustHaveCorrectAmount 12 threadcrash.c: || ((FAILURES++))
+    
+    mustHaveSevenThreads || ((FAILURES++))
+    mustHaveSequence sleep "makeSyscall (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence sleep "syscallingSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
+    mustHaveSequence pthread_kill "makeSyscallFromSighandler (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence sleep "syscallingAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
+    mustHaveSequence pthread_kill "makeSyscallFromAltSighandler (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence Thread "spin (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence "spinningSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
+    mustHaveSequence pthread_kill "spinFromSighandler (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence "spinningAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
+    mustHaveSequence pthread_kill "spinFromAltSighandler (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence Thread "main (argc=1, argv=" || ((FAILURES++))
+
+    return $FAILURES
+}
+
+# Put result of debugging a core file in $LOG
+function getLogFromCore() {
+    # Make sure we get a core file
+    set_test Make sure we get a core file
+    if ! ulimit -c unlimited ; then
+        fail
+        exit 1
+    fi
+    pass
+
+    # Run the crasher
+    ./$(basename "$RUNME")
+    EXITCODE=$?
+
+    # Verify that we actually crashed
+    set_test $RUNME should have been killed by a signal, got non-signal exit code $EXITCODE
+    if [ $EXITCODE -lt 128 ] ; then
+        fail
+        exit 1
+    fi
+    pass
+
+    # Verify that we got a core file
+    set_test $RUNME did not create a core file
+    if [ ! -r core* ] ; then
+        fail
+        exit 1
+    fi
+    pass
+
+    # Run gdb
+    cat > gdbscript.gdb <<EOF
+set width 0
+t a a bt 100
+quit
+EOF
+    cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" core* > $LOG
+    EXITCODE=$?
+
+    set_test gdb exited with error code
+    if [ $EXITCODE != 0 ] ; then
+        ((FAILURES++))
+        echo >&2 gdb exited with error code $EXITCODE
+	fail
+    fi
+    pass
+}
+
+# Put result of debugging a gcore file in $LOG
+function getLogFromGcore() {
+    # Create the core file
+    rm -f core*
+    cat > gdbscript.gdb <<EOF
+handle SIGQUIT pass noprint nostop
+handle SIGUSR1 pass noprint nostop
+handle SIGUSR2 pass noprint nostop
+handle SIGALRM pass noprint nostop
+run
+gcore
+quit
+EOF
+    cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" > /dev/null
+    EXITCODE=$?
+
+    set_test gdb exited with error code when creating gcore file
+    if [ $EXITCODE != 0 ] ; then
+        ((FAILURES++))
+        echo >&2 gdb exited with error code $EXITCODE when creating gcore file
+	fail
+    fi
+    pass
+    
+    # Verify that we got a core file from gcore
+    set_test gdb gcore did not create a core file
+    if [ ! -r core* ] ; then
+        fail
+        exit 1
+    fi
+    pass
+
+    # Run gdb on the gcore file
+    cat > gdbscript.gdb <<EOF
+set width 0
+t a a bt 100
+quit
+EOF
+    cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" core* > $LOG
+    EXITCODE=$?
+
+    set_test gdb exited with error code when examining gcore file
+    if [ $EXITCODE != 0 ] ; then
+        ((FAILURES++))
+        echo >&2 gdb exited with error code $EXITCODE when examining gcore file
+	fail
+    fi
+    pass
+}
+
+# Put result of debugging a core file in $LOG
+function getLogFromLiveProcess() {
+    # Run gdb
+    cat > gdbscript.gdb <<EOF
+handle SIGQUIT pass noprint nostop
+handle SIGUSR1 pass noprint nostop
+handle SIGUSR2 pass noprint nostop
+handle SIGALRM pass noprint nostop
+set width 0
+run
+t a a bt 100
+quit
+EOF
+    cat gdbscript.gdb /dev/zero | $GDB -nx "./$(basename "$RUNME")" > $LOG
+    EXITCODE=$?
+
+    set_test gdb exited with error code
+    if [ $EXITCODE != 0 ] ; then
+        ((FAILURES++))
+        echo >&2 gdb exited with error code $EXITCODE
+	fail
+    fi
+    pass
+}
+
+####### Main program follows #####################
+
+# Make sure we don't clobber anybody else's (core) file(s)
+WORKDIR=/tmp/$PPID
+mkdir -p $WORKDIR
+cp "$RUNME" $WORKDIR
+cd $WORKDIR
+
+# Count problems
+FAILURES=0
+
+echo === Testing gdb vs core file...
+pf_prefix core file
+getLogFromCore
+verifyLog
+((FAILURES+=$?))
+pf_prefix
+echo === Core file tests done.
+
+echo
+
+echo === Testing gdb vs gcore file...
+pf_prefix gcore file
+getLogFromGcore
+verifyLog
+((FAILURES+=$?))
+pf_prefix
+echo === Gcore file tests done.
+
+echo
+
+echo === Testing gdb vs live process...
+pf_prefix live process
+getLogFromLiveProcess
+verifyLog
+((FAILURES+=$?))
+pf_prefix
+echo === Live process tests done.
+
+# Executive summary
+echo
+if [ $FAILURES == 0 ] ; then
+    echo All tests passed!
+else
+    echo $FAILURES tests failed!
+    echo
+    echo Make sure the threadcrash binary contains debugging information \(build with \"gcc -g\"\).
+fi
+
+# Clean up
+cd /
+rm -rf $WORKDIR
+
+exit $FAILURES
Index: ./gdb/testsuite/gdb.threads/threadcrash.sh-orig
===================================================================
RCS file: gdb/testsuite/gdb.threads/threadcrash.sh-orig
diff -N gdb/testsuite/gdb.threads/threadcrash.sh-orig
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.threads/threadcrash.sh-orig	31 Oct 2006 17:54:38 -0000
@@ -0,0 +1,248 @@
+#! /bin/bash
+
+# NOTE: threadcrash.c *must* be built with debugging symbols
+#
+# The point of this shell script is to crash treadcrash.c, load the
+# resulting core file into gdb and verify that gdb can extract enough
+# information from the core file.
+#
+# The return code from this script is the number of failed tests.
+
+LOG=gdbresult.log
+
+if [ $# != 1 ] ; then
+    echo > /dev/stderr Syntax: $0 \<name of threadcrash binary\>
+    exit 1
+fi
+RUNME="$1"
+
+# Verify that the gdb output doesn't contain $1.
+function mustNotHave() {
+    local BADWORD=$1
+    if grep -q "$BADWORD" $LOG ; then
+        echo >> /dev/stderr WARNING: gdb output contains "$BADWORD"
+        return 1
+    fi
+    return 0
+}
+
+# Verify that the gdb output contains exactly $1 $2s.
+function mustHaveCorrectAmount() {
+    local WANTEDNUMBER=$1
+    local GOODWORD=$2
+    local ACTUALNUMBER=$(grep "$GOODWORD" $LOG | wc -l)
+    if [ $ACTUALNUMBER != $WANTEDNUMBER ] ; then
+        echo >> /dev/stderr WARNING: gdb output contained $ACTUALNUMBER \""$GOODWORD"\", not $WANTEDNUMBER as expected
+        return 1
+    fi
+    return 0
+}
+
+# Verify that the gdb output contains seven threads
+function mustHaveSevenThreads() {
+    NTHREADS=$(egrep "^Thread [1-7] \(" $LOG | wc -l)
+    if [ $NTHREADS != 7 ] ; then
+        echo >> /dev/stderr WARNING: gdb output contains $NTHREADS threads, not 7 as expected
+        return 1
+    fi
+    return 0
+}
+
+# Verify that the gdb output has all parameters on consecutive lines
+function mustHaveSequence() {
+    SEQUENCE="$*"
+    NPARTS=$#
+    grep "$1" -A$((NPARTS - 1)) $LOG > matches.log
+
+    while [ $# -gt 1 ] ; do
+        shift
+        ((NPARTS--))
+        grep "$1" -A$((NPARTS - 1)) matches.log > temp.log
+        mv temp.log matches.log
+    done
+    LASTPART=$1
+
+    if ! grep -q "$LASTPART" matches.log ; then
+        echo >> /dev/stderr WARNING: gdb output does not contain the sequence: $SEQUENCE
+        return 1
+    fi
+    return 0
+}
+
+# Verify that $LOG contains all information we want
+function verifyLog() {
+    local FAILURES=0
+    
+    mustNotHave '??' || ((FAILURES++))
+    mustHaveCorrectAmount 12 threadcrash.c: || ((FAILURES++))
+    
+    mustHaveSevenThreads || ((FAILURES++))
+    mustHaveSequence sleep "makeSyscall (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence sleep "syscallingSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
+    mustHaveSequence pthread_kill "makeSyscallFromSighandler (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence sleep "syscallingAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
+    mustHaveSequence pthread_kill "makeSyscallFromAltSighandler (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence Thread "spin (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence "spinningSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
+    mustHaveSequence pthread_kill "spinFromSighandler (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence "spinningAltSighandler (signo=" "signal handler called" 0x || ((FAILURES++))
+    mustHaveSequence pthread_kill "spinFromAltSighandler (ignored=" || ((FAILURES++))
+    
+    mustHaveSequence Thread "main (argc=1, argv=" || ((FAILURES++))
+
+    return $FAILURES
+}
+
+# Put result of debugging a core file in $LOG
+function getLogFromCore() {
+    # Make sure we get a core file
+    ulimit -c unlimited || exit 1
+
+    # Run the crasher
+    ./$(basename "$RUNME")
+    EXITCODE=$?
+
+    # Verify that we actually crashed
+    if [ $EXITCODE -lt 128 ] ; then
+        echo >> /dev/stderr ERROR: $RUNME should have been killed by a signal, got non-signal exit code $EXITCODE
+        exit 1
+    fi
+
+    # Verify that we got a core file
+    if [ ! -r core* ] ; then
+        echo >> /dev/stderr ERROR: $RUNME did not create a core file
+        exit 1
+    fi
+
+    # Run gdb
+    cat > gdbscript.gdb <<EOF
+set width 0
+t a a bt 100
+quit
+EOF
+    cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" core* > $LOG
+    EXITCODE=$?
+
+    if [ $EXITCODE != 0 ] ; then
+        ((FAILURES++))
+        echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE
+    fi
+}
+
+# Put result of debugging a gcore file in $LOG
+function getLogFromGcore() {
+    # Create the core file
+    rm -f core*
+    cat > gdbscript.gdb <<EOF
+handle SIGQUIT pass noprint nostop
+handle SIGUSR1 pass noprint nostop
+handle SIGUSR2 pass noprint nostop
+handle SIGALRM pass noprint nostop
+run
+gcore
+quit
+EOF
+    cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" > /dev/null
+    EXITCODE=$?
+
+    if [ $EXITCODE != 0 ] ; then
+        ((FAILURES++))
+        echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE when creating gcore file
+    fi
+    
+    # Verify that we got a core file from gcore
+    if [ ! -r core* ] ; then
+        echo >> /dev/stderr ERROR: gdb gcore did not create a core file
+        exit 1
+    fi
+
+    # Run gdb on the gcore file
+    cat > gdbscript.gdb <<EOF
+set width 0
+t a a bt 100
+quit
+EOF
+    cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" core* > $LOG
+    EXITCODE=$?
+
+    if [ $EXITCODE != 0 ] ; then
+        ((FAILURES++))
+        echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE when examining gcore file
+    fi
+}
+
+# Put result of debugging a core file in $LOG
+function getLogFromLiveProcess() {
+    # Run gdb
+    cat > gdbscript.gdb <<EOF
+handle SIGQUIT pass noprint nostop
+handle SIGUSR1 pass noprint nostop
+handle SIGUSR2 pass noprint nostop
+handle SIGALRM pass noprint nostop
+set width 0
+run
+t a a bt 100
+quit
+EOF
+    cat gdbscript.gdb /dev/zero | gdb -nx "./$(basename "$RUNME")" > $LOG
+    EXITCODE=$?
+
+    if [ $EXITCODE != 0 ] ; then
+        ((FAILURES++))
+        echo >> /dev/stderr WARNING: gdb exited with error code $EXITCODE
+    fi
+}
+
+####### Main program follows #####################
+
+# Make sure we don't clobber anybody else's (core) file(s)
+WORKDIR=/tmp/$PPID
+mkdir -p $WORKDIR
+cp "$RUNME" $WORKDIR
+cd $WORKDIR
+
+# Count problems
+FAILURES=0
+
+echo === Testing gdb vs core file...
+getLogFromCore
+verifyLog
+((FAILURES+=$?))
+echo === Core file tests done.
+
+echo
+
+echo === Testing gdb vs gcore file...
+getLogFromGcore
+verifyLog
+((FAILURES+=$?))
+echo === Gcore file tests done.
+
+echo
+
+echo === Testing gdb vs live process...
+getLogFromLiveProcess
+verifyLog
+((FAILURES+=$?))
+echo === Live process tests done.
+
+# Executive summary
+echo
+if [ $FAILURES == 0 ] ; then
+    echo All tests passed!
+else
+    echo $FAILURES tests failed!
+    echo
+    echo Make sure the threadcrash binary contains debugging information \(build with \"gcc -g\"\).
+fi
+
+# Clean up
+cd /
+rm -rf $WORKDIR
+
+exit $FAILURES

gdb-6.5-last-address-space-byte-test.patch:
 largecore-last-address-lock.exp |   49 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+)

--- NEW FILE gdb-6.5-last-address-space-byte-test.patch ---
Index: ./gdb/testsuite/gdb.base/largecore-last-address-lock.exp
===================================================================
RCS file: ./gdb/testsuite/gdb.base/largecore-last-address-lock.exp
diff -N ./gdb/testsuite/gdb.base/largecore-last-address-lock.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.base/largecore-last-address-lock.exp	15 Nov 2006 21:43:24 -0000
@@ -0,0 +1,49 @@
+# Copyright 2006 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.  
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+# Get things started.
+
+gdb_exit
+gdb_start
+
+# i386 (32-bit) only: gdb with Red Hat largecore patch did lock up:
+# https://enterprise.redhat.com/issue-tracker/?module=issues&action=view&tid=103263
+# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=210614
+
+# i386: Bug exists when the `target_xfer_memory' condition
+# `(memaddr + len < region->hi)' operates on 64-bit operands on
+# largecore-patched with 32-bit addresses and so it can get `false' with
+# arbitrary `len'.
+
+# x86_64: The bug is not present as the operands and calculations have the same
+# bit size.  Would would still need to pass there the highest address
+# (`memaddr == 0xffffffffffffffff') but we would need to pass `len == 0'
+# to make the condition `(memaddr + len < region->hi)' false.
+# `len == 0' would get caught eariler.
+
+# Error in the success case is immediate.
+set timeoutold ${timeout}
+set timeout 10
+
+gdb_test "x/xb 0xffffffff" \
+         "Cannot access memory at address 0xffffffff" \
+         "Read the last address space byte"
+
+set timeout ${timeoutold}

gdb-6.5-matching_bfd_sections.patch:
 Makefile.in |    2 -
 minsyms.c   |    4 +--
 printcmd.c  |    5 ++++
 symtab.c    |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 symtab.h    |    2 +
 5 files changed, 72 insertions(+), 6 deletions(-)

--- NEW FILE gdb-6.5-matching_bfd_sections.patch ---
2006-10-17  Daniel Jacobowitz  <dan at codesourcery.com>

	* Makefile.in (symtab.o): Update.
	* symtab.h (matching_bfd_sections): New prototype.
	* symtab.c (matching_bfd_sections): New.
	(find_pc_sect_psymbol, find_pc_sect_symtab): Use it.
	* minsyms.c (lookup_minimal_symbol_by_pc_section): Likewise.
	* printcmd.c (sym_info): Ignore separate debug objfiles.


Index: ./gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.846
retrieving revision 1.847
diff -u -p -r1.846 -r1.847
--- ./gdb/Makefile.in	10 Oct 2006 03:17:53 -0000	1.846
+++ ./gdb/Makefile.in	17 Oct 2006 20:17:44 -0000	1.847
@@ -2754,7 +2754,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h)
 	$(language_h) $(demangle_h) $(inferior_h) $(linespec_h) $(source_h) \
 	$(filenames_h) $(objc_lang_h) $(ada_lang_h) $(hashtab_h) \
 	$(gdb_obstack_h) $(block_h) $(dictionary_h) $(gdb_string_h) \
-	$(gdb_stat_h) $(cp_abi_h) $(observer_h)
+	$(gdb_stat_h) $(cp_abi_h) $(observer_h) $(gdb_assert_h)
 target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
 	$(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
 	$(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) $(gdbcore_h) \
diff -u -p
--- ./gdb/minsyms.c	19 Jul 2006 02:17:23 -0000	1.46
+++ ./gdb/minsyms.c	17 Oct 2006 20:17:44 -0000	1.47
@@ -360,7 +360,6 @@ lookup_minimal_symbol_solib_trampoline (
   return NULL;
 }
 
-
 /* Search through the minimal symbol table for each objfile and find
    the symbol whose address is the largest address that is still less
    than or equal to PC, and matches SECTION (if non-NULL).  Returns a
@@ -491,7 +490,8 @@ lookup_minimal_symbol_by_pc_section (COR
 		       /* Don't ignore symbols for solib trampolines
 			  Red Hat Bug 200533 and Bug 192964.  */
 		       && MSYMBOL_TYPE (&msymbol[hi]) != mst_solib_trampoline
-		       && SYMBOL_BFD_SECTION (&msymbol[hi]) != section)
+		      && (!matching_bfd_sections
+			  (SYMBOL_BFD_SECTION (&msymbol[hi]), section)))
 		  --hi;
 
 	      if (hi >= 0
Index: ./gdb/printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -p -r1.98 -r1.99
--- ./gdb/printcmd.c	17 Jul 2006 22:15:55 -0000	1.98
+++ ./gdb/printcmd.c	17 Oct 2006 20:17:44 -0000	1.99
@@ -983,6 +983,11 @@ sym_info (char *arg, int from_tty)
   addr = parse_and_eval_address (arg);
   ALL_OBJSECTIONS (objfile, osect)
   {
+    /* Only process each object file once, even if there's a separate
+       debug file.  */
+    if (objfile->separate_debug_objfile_backlink)
+      continue;
+
     sect = osect->the_bfd_section;
     sect_addr = overlay_mapped_address (addr, sect);
 
Index: ./gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -p -r1.147 -r1.148
--- ./gdb/symtab.c	11 May 2006 09:29:52 -0000	1.147
+++ ./gdb/symtab.c	17 Oct 2006 20:17:44 -0000	1.148
@@ -56,6 +56,7 @@
 #include <ctype.h>
 #include "cp-abi.h"
 #include "observer.h"
+#include "gdb_assert.h"
 
 /* Prototypes for local functions */
 
@@ -706,6 +707,64 @@ init_sal (struct symtab_and_line *sal)
 }
 
 
+/* Return 1 if the two sections are the same, or if they could
+   plausibly be copies of each other, one in an original object
+   file and another in a separated debug file.  */
+
+int
+matching_bfd_sections (asection *first, asection *second)
+{
+  struct objfile *obj;
+
+  /* If they're the same section, then they match.  */
+  if (first == second)
+    return 1;
+
+  /* If either is NULL, give up.  */
+  if (first == NULL || second == NULL)
+    return 0;
+
+  /* This doesn't apply to absolute symbols.  */
+  if (first->owner == NULL || second->owner == NULL)
+    return 0;
+
+  /* If they're in the same object file, they must be different sections.  */
+  if (first->owner == second->owner)
+    return 0;
+
+  /* Check whether the two sections are potentially corresponding.  They must
+     have the same size, address, and name.  We can't compare section indexes,
+     which would be more reliable, because some sections may have been
+     stripped.  */
+  if (bfd_get_section_size (first) != bfd_get_section_size (second))
+    return 0;
+
+  if (bfd_get_section_vma (first->owner, first)
+      != bfd_get_section_vma (second->owner, second))
+    return 0;
+
+  if (bfd_get_section_name (first->owner, first) == NULL
+      || bfd_get_section_name (second->owner, second) == NULL
+      || strcmp (bfd_get_section_name (first->owner, first),
+		 bfd_get_section_name (second->owner, second)) != 0)
+    return 0;
+
+  /* Otherwise check that they are in corresponding objfiles.  */
+
+  ALL_OBJFILES (obj)
+    if (obj->obfd == first->owner)
+      break;
+  gdb_assert (obj != NULL);
+
+  if (obj->separate_debug_objfile != NULL
+      && obj->separate_debug_objfile->obfd == second->owner)
+    return 1;
+  if (obj->separate_debug_objfile_backlink != NULL
+      && obj->separate_debug_objfile_backlink->obfd == second->owner)
+    return 1;
+
+  return 0;
+}
 
 /* Find which partial symtab contains PC and SECTION.  Return 0 if
    none.  We return the psymtab that contains a symbol whose address
@@ -845,7 +904,7 @@ find_pc_sect_psymbol (struct partial_sym
 	  if (section)		/* match on a specific section */
 	    {
 	      fixup_psymbol_section (p, psymtab->objfile);
-	      if (SYMBOL_BFD_SECTION (p) != section)
+	      if (!matching_bfd_sections (SYMBOL_BFD_SECTION (p), section))
 		continue;
 	    }
 	  best_pc = SYMBOL_VALUE_ADDRESS (p);
@@ -869,7 +928,7 @@ find_pc_sect_psymbol (struct partial_sym
 	  if (section)		/* match on a specific section */
 	    {
 	      fixup_psymbol_section (p, psymtab->objfile);
-	      if (SYMBOL_BFD_SECTION (p) != section)
+	      if (!matching_bfd_sections (SYMBOL_BFD_SECTION (p), section))
 		continue;
 	    }
 	  best_pc = SYMBOL_VALUE_ADDRESS (p);
@@ -1902,7 +1961,7 @@ find_pc_sect_symtab (CORE_ADDR pc, asect
 	    ALL_BLOCK_SYMBOLS (b, iter, sym)
 	      {
 		fixup_symbol_section (sym, objfile);
-		if (section == SYMBOL_BFD_SECTION (sym))
+		if (matching_bfd_sections (SYMBOL_BFD_SECTION (sym), section))
 		  break;
 	      }
 	    if (sym == NULL)
Index: ./gdb/symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -p -r1.97 -r1.98
--- ./gdb/symtab.h	18 Mar 2006 18:40:04 -0000	1.97
+++ ./gdb/symtab.h	17 Oct 2006 20:17:45 -0000	1.98
@@ -1316,6 +1316,8 @@ extern char **make_source_files_completi
 
 /* symtab.c */
 
+int matching_bfd_sections (asection *, asection *);
+
 extern struct partial_symtab *find_main_psymtab (void);
 
 extern struct symtab *find_line_symtab (struct symtab *, int, int *, int *);

gdb-6.5-readline-long-line-crash.patch:
 display.c |   63 ++++++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 41 insertions(+), 22 deletions(-)

--- NEW FILE gdb-6.5-readline-long-line-crash.patch ---
Fix Valgrind paste of >= 256 * (screen width) characters (as 130001).

Invalid write of size 4
   at 0x8203BD9: rl_redisplay (display.c:812)
   by 0x81F5130: _rl_internal_char_cleanup (readline.c:427)
   by 0x81F52B3: readline_internal_char (readline.c:508)
   by 0x8209817: rl_callback_read_char (callback.c:184)
   by 0x8135312: rl_callback_read_char_wrapper (event-top.c:179)
   by 0x8135B7B: stdin_event_handler (event-top.c:432)
   by 0x81349F2: handle_file_event (event-loop.c:730)
   by 0x81342AB: process_event (event-loop.c:343)
   by 0x81342F4: gdb_do_one_event (event-loop.c:380)
   by 0x81313AC: catch_errors (exceptions.c:515)
   by 0x80CE8CA: tui_command_loop (tui-interp.c:151)
   by 0x81318B9: current_interp_command_loop (interps.c:278)
 Address 0x43DCEB8 is 0 bytes after a block of size 1,024 alloc'd
   at 0x4005400: malloc (vg_replace_malloc.c:149)
   by 0x8087084: xmalloc (utils.c:959)
   by 0x8202CA7: init_line_structures (display.c:440)
   by 0x8202D14: rl_redisplay (display.c:471)
   by 0x81F4F53: readline_internal_setup (readline.c:363)
   by 0x820958C: _rl_callback_newline (callback.c:89)
   by 0x82095BB: rl_callback_handler_install (callback.c:101)
   by 0x80CE896: tui_command_loop (tui-interp.c:138)
   by 0x81318B9: current_interp_command_loop (interps.c:278)
   by 0x807E69A: captured_command_loop (main.c:101)
   by 0x81313AC: catch_errors (exceptions.c:515)
   by 0x807F55A: captured_main (main.c:826)


2006-11-08  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* readline/display.c (line_state, line_state_array, line_state_visible,
	line_state_invisible): Encapsulate _rl_wrapped_line, inv_lbreaks,
	inv_lbsize, vis_lbreaks, vis_lbsize, visible_line, invisible_line.
	(init_line_structures): Initialize both _rl_wrapped_line ones now.
	(rl_redisplay): Fix _rl_wrapped_line handling by using its own size.
	Swap whole `line_state_visible' / `line_state_invisible' structures.
	(update_line): Update for new `_rl_wrapped_line'.


Index: ./readline/display.c
===================================================================
--- ./readline/display.c	5 May 2006 18:26:12 -0000	1.11
+++ ./readline/display.c	8 Nov 2006 18:23:33 -0000
@@ -73,15 +73,31 @@ static void delete_chars PARAMS((int));
 static void insert_some_chars PARAMS((char *, int, int));
 static void cr PARAMS((void));
 
+struct line_state
+  {
+    char *line;
+    int *lbreaks;
+    int lbreaks_size;
+#if defined (HANDLE_MULTIBYTE)
+    int *wrapped_line;
+    int wrapped_line_size;
+#endif
+  };
+static struct line_state line_state_array[2];
+static struct line_state *line_state_visible = &line_state_array[0];
+static struct line_state *line_state_invisible = &line_state_array[1];
+
 #if defined (HANDLE_MULTIBYTE)
 static int _rl_col_width PARAMS((const char *, int, int));
-static int *_rl_wrapped_line;
 #else
 #  define _rl_col_width(l, s, e)	(((e) <= (s)) ? 0 : (e) - (s))
 #endif
 
-static int *inv_lbreaks, *vis_lbreaks;
-static int inv_lbsize, vis_lbsize;
+/* FIXME: Backward compatible naming. */
+#define inv_lbreaks (line_state_invisible->lbreaks)
+#define inv_lbsize (line_state_invisible->lbreaks_size)
+#define vis_lbreaks (line_state_visible->lbreaks)
+#define vis_lbsize (line_state_visible->lbreaks_size)
 
 /* Heuristic used to decide whether it is faster to move from CUR to NEW
    by backing up or outputting a carriage return and moving forward. */
@@ -150,8 +166,9 @@ static int last_lmargin;
 
 /* The line display buffers.  One is the line currently displayed on
    the screen.  The other is the line about to be displayed. */
-static char *visible_line = (char *)NULL;
-static char *invisible_line = (char *)NULL;
+/* FIXME: Backward compatible naming. */
+#define visible_line (line_state_visible->line)
+#define invisible_line (line_state_invisible->line)
 
 /* A buffer for `modeline' messages. */
 static char msg_buf[128];
@@ -437,7 +454,10 @@ init_line_structures (minsize)
       inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
       vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
 #if defined (HANDLE_MULTIBYTE)
-      _rl_wrapped_line = (int *)xmalloc (vis_lbsize * sizeof (int));
+      line_state_visible->wrapped_line_size = vis_lbsize;
+      line_state_visible->wrapped_line = (int *)xmalloc (line_state_visible->wrapped_line_size * sizeof (int));
+      line_state_invisible->wrapped_line_size = inv_lbsize;
+      line_state_invisible->wrapped_line = (int *)xmalloc (line_state_invisible->wrapped_line_size * sizeof (int));
 #endif
       inv_lbreaks[0] = vis_lbreaks[0] = 0;
     }
@@ -572,10 +592,15 @@ rl_redisplay ()
 	      { \
 		inv_lbsize *= 2; \
 		inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
-		_rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
 	      } \
 	    inv_lbreaks[++newlines] = out; \
-	    _rl_wrapped_line[newlines] = _rl_wrapped_multicolumn; \
+	    if (newlines >= (line_state_invisible->wrapped_line_size - 1)) \
+	      { \
+		line_state_invisible->wrapped_line_size *= 2; \
+		line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, \
+		  line_state_invisible->wrapped_line_size * sizeof (int)); \
+	      } \
+	    line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; \
 	    lpos = 0; \
 	  } \
       } while (0)
@@ -605,7 +630,7 @@ rl_redisplay ()
 #endif
 
 #if defined (HANDLE_MULTIBYTE)
-  memset (_rl_wrapped_line, 0, vis_lbsize);
+  memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wrapped_line_size * sizeof (int));
   num = 0;
 #endif
 
@@ -1118,17 +1143,10 @@ rl_redisplay ()
 
   /* Swap visible and non-visible lines. */
   {
-    char *vtemp = visible_line;
-    int *itemp = vis_lbreaks, ntemp = vis_lbsize;
-
-    visible_line = invisible_line;
-    invisible_line = vtemp;
-
-    vis_lbreaks = inv_lbreaks;
-    inv_lbreaks = itemp;
-
-    vis_lbsize = inv_lbsize;
-    inv_lbsize = ntemp;
+    struct line_state *line_state_temp = line_state_visible;
+    
+    line_state_visible = line_state_invisible;
+    line_state_invisible = line_state_temp;
 
     rl_display_fixed = 0;
     /* If we are displaying on a single line, and last_lmargin is > 0, we
@@ -1194,8 +1212,9 @@ update_line (old, new, current_line, oma
 	  /* This fixes only double-column characters, but if the wrapped
 	     character comsumes more than three columns, spaces will be
 	     inserted in the string buffer. */
-	  if (_rl_wrapped_line[current_line] > 0)
-	    _rl_clear_to_eol (_rl_wrapped_line[current_line]);
+	  if (current_line < line_state_visible->wrapped_line_size
+	      && line_state_visible->wrapped_line[current_line] > 0)
+	    _rl_clear_to_eol (line_state_visible->wrapped_line[current_line]);
 
 	  memset (&ps, 0, sizeof (mbstate_t));
 	  ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps);

gdb-6.5-relativedebug.patch:
 symtab.c                             |    5 ++
 testsuite/gdb.base/relativedebug.c   |   37 +++++++++++++++++++
 testsuite/gdb.base/relativedebug.exp |   68 +++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+), 1 deletion(-)

--- NEW FILE gdb-6.5-relativedebug.patch ---
2006-10-29  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* gdb/symtab.c (matching_bfd_sections): Fix VMA matching for objects
	loaded at a different address than stored on the disk.

2006-10-29  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* gdb.base/relativedebug.c, gdb.base/relativedebug.exp: New file, 
	resolving of PC in libc pause(3) (with possibly different on-disk VMA).


Index: ./gdb/symtab.c
===================================================================
--- ./gdb/symtab.c	17 Oct 2006 20:17:44 -0000	1.148
+++ ./gdb/symtab.c	29 Oct 2006 22:29:21 -0000
@@ -739,8 +739,11 @@ matching_bfd_sections (asection *first, 
   if (bfd_get_section_size (first) != bfd_get_section_size (second))
     return 0;
 
+  /* In-memory addresses may start at a different offset, relativize them.  */
   if (bfd_get_section_vma (first->owner, first)
-      != bfd_get_section_vma (second->owner, second))
+      - bfd_get_start_address (first->owner)
+      != bfd_get_section_vma (second->owner, second)
+	 - bfd_get_start_address (second->owner))
     return 0;
 
   if (bfd_get_section_name (first->owner, first) == NULL
Index: ./gdb/testsuite/gdb.base/relativedebug.c
===================================================================
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.base/relativedebug.c	29 Oct 2006 22:29:21 -0000
@@ -0,0 +1,37 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2006 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.  */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <signal.h>
+
+
+static void handler (int signo)
+{
+	abort ();
+}
+
+int main (void)
+{
+	signal (SIGALRM, handler);
+	alarm (1);
+	pause ();
+	pause ();
+	return 0;
+}
Index: ./gdb/testsuite/gdb.base/relativedebug.exp
===================================================================
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.base/relativedebug.exp	29 Oct 2006 22:29:21 -0000
@@ -0,0 +1,68 @@
+# Copyright 2006 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.  
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set testfile relativedebug
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+    untested "Couldn't compile test program"
+    return -1
+}
+
+# Get things started.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# pause () -> SIGALRM -> handler () -> abort ()
+
+gdb_test "run" \
+         ".*Program received signal SIGABRT, Aborted..*" \
+         "run"
+
+# incorrect (#6):
+# (gdb) bt
+# #0  0x00325402 in __kernel_vsyscall ()
+# #1  0x00718f20 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
+# #2  0x0071a801 in *__GI_abort () at abort.c:88
+# #3  0x0804841f in handler (signo=14) at ./gdb.base/relativedebug.c:27
+# #4  <signal handler called>
+# #5  0x00325402 in __kernel_vsyscall ()
+# #6  0x0077ebc6 in ?? () from /lib/i686/nosegneg/libc.so.6
+# #7  0x08048455 in main () at ./gdb.base/relativedebug.c:34
+# (gdb)
+
+# correct (#6):
+# (gdb) bt
+# #0  0x00b33402 in __kernel_vsyscall ()
+# #1  0x00718f20 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
+# #2  0x0071a801 in *__GI_abort () at abort.c:88
+# #3  0x0804841f in handler (signo=14) at ./gdb.base/relativedebug.c:27
+# #4  <signal handler called>
+# #5  0x00b33402 in __kernel_vsyscall ()
+# #6  0x0077ebc6 in __pause_nocancel () from /lib/i686/nosegneg/libc.so.6
+# #7  0x08048455 in main () at ./gdb.base/relativedebug.c:34
+# (gdb)
+
+gdb_test "bt" \
+         ".*\[^a-zA-Z\]pause\[^a-zA-Z\].*" \
+         "pause(3) seen there"

gdb-6.5-symbols-overlap.patch:
 ./gdb/testsuite/gdb.arch/i386-size-overlap.c   |   53 ++++++++++++++++
 ./gdb/testsuite/gdb.arch/i386-size-overlap.exp |   79 +++++++++++++++++++++++++
 gdb-6.5/gdb/minsyms.c                          |   24 ++++++-
 3 files changed, 154 insertions(+), 2 deletions(-)

--- NEW FILE gdb-6.5-symbols-overlap.patch ---
2006-10-30  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* gdb/minsyms.c (lookup_minimal_symbol_by_pc_section): Handle
	overlapping non-zero sized functions (for glibc `__nanosleep').

2006-10-30  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* gdb.arch/i386-size-overlap.c, gdb.arch/i386-size-overlap.exp: New
	file, provide nested (overlapping) functions for the PC resolving.


--- gdb-6.5/gdb/minsyms.c-orig	2006-10-31 08:21:32.000000000 -0500
+++ gdb-6.5/gdb/minsyms.c	2006-10-31 08:24:37.000000000 -0500
@@ -464,6 +464,7 @@
 	         objfile's minimal symbol table.  See if it is the best one
 	         overall. */
 
+	      while (0
 	      /* Skip any absolute symbols.  This is apparently what adb
 	         and dbx do, and is needed for the CM-5.  There are two
 	         known possible problems: (1) on ELF, apparently end, edata,
@@ -473,8 +474,27 @@
 	         NeXT are absolute.  If we want special handling for this
 	         it probably should be triggered by a special
 	         mst_abs_or_lib or some such.  */
-	      while (hi >= 0
-		     && msymbol[hi].type == mst_abs)
+		     || (hi >= 0
+			 && msymbol[hi].type == mst_abs)
+		  /* We are behind the current symbol's size.
+		     Try the previous symbol - if it is non-zero sized one it
+		     may overlap the current one and reach our PC.
+		     It occurs for GNU/Linux glibc `__nanosleep' overlapping
+		     later `__nanosleep_nocancel' with PC at 0077ec66:
+   Num:    Value  Size Type    Bind   Vis      Ndx Name
+  7247: 0077ec20   124 FUNC    WEAK   DEFAULT   11 __nanosleep
+  4651: 0077ec2a    32 FUNC    LOCAL  DEFAULT   11 __nanosleep_nocancel
+		     Test `gdb.arch/i386-size' + `gdb.arch/i386-unwind'.
+		     Limit it only for the overlapping cases as we could harm
+		     the zero-sized symbols detection logic around.
+		     */
+		     || (hi > 0
+			 && MSYMBOL_SIZE (&msymbol[hi]) != 0
+			 && pc >= (SYMBOL_VALUE_ADDRESS (&msymbol[hi])
+				   + MSYMBOL_SIZE (&msymbol[hi]))
+			 && pc < (SYMBOL_VALUE_ADDRESS (&msymbol[hi - 1])
+				  + MSYMBOL_SIZE (&msymbol[hi - 1])))
+		     )
 		--hi;
 
 	      /* If "section" specified, skip any symbol from wrong section */
Index: ./gdb/testsuite/gdb.arch/i386-size-overlap.c
===================================================================
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.arch/i386-size-overlap.c	30 Oct 2006 12:41:35 -0000
@@ -0,0 +1,53 @@
+/* Overlapping symbol sizes test program.
+
+   Copyright 2006 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 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.  */
+
+#ifdef SYMBOL_PREFIX
+#define SYMBOL(str)	SYMBOL_PREFIX #str
+#else
+#define SYMBOL(str)	#str
+#endif
+
+void
+trap (void)
+{
+  asm ("int $0x03");
+}
+
+/* Jump from a function with its symbol size set, to a function
+   named by a local label.  GDB should report the `main' function
+   even for the rest, after the global `inner' ends.  */
+
+asm(".text\n"
+    "    .align 8\n"
+    "    .globl " SYMBOL (main) "\n"
+    SYMBOL (main) ":\n"
+    "    pushl %ebp\n"
+    "    mov   %esp, %ebp\n"
+    "    call  .Lfunc\n"
+    "    ret\n"
+    SYMBOL (inner) ":\n"
+    "    ret\n"
+    "    .size " SYMBOL (inner) ", .-" SYMBOL (inner) "\n"
+    ".Lfunc:\n"
+    "    pushl %ebp\n"
+    "    mov   %esp, %ebp\n"
+    "    call  " SYMBOL (trap) "\n"
+    "    .size " SYMBOL (main) ", .-" SYMBOL (main) "\n");
Index: ./gdb/testsuite/gdb.arch/i386-size-overlap.exp
===================================================================
RCS file: gdb/testsuite/gdb.arch/i386-size-overlap.exp
diff -N gdb/testsuite/gdb.arch/i386-size-overlap.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ./gdb/testsuite/gdb.arch/i386-size-overlap.exp	30 Oct 2006 12:41:35 -0000
@@ -0,0 +1,79 @@
+# Copyright 2006 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 at gnu.org
+
+# This file is part of the gdb testsuite.
+
+if $tracelevel {
+    strace $tracelevel
+}
+
+# Test that GDB can handle overlapping sizes of symbols.
+
+if ![istarget "i?86-*-*"] then {
+    verbose "Skipping i386 unwinder tests."
+    return
+}
+
+set testfile "i386-size-overlap"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+# some targets have leading underscores on assembly symbols.
+# TODO: detect this automatically
+set additional_flags ""
+if [istarget "i?86-*-cygwin*"] then {
+  set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\""
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+	  executable [list debug $additional_flags]] != "" } {
+    untested "i386-size"
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# We use gdb_run_cmd so this stands a chance to work for remote
+# targets too.
+gdb_run_cmd
+
+gdb_expect {
+    -re "Program received signal SIGTRAP.*$gdb_prompt $" {
+	pass "run past main"
+    }
+    -re ".*$gdb_prompt $" {
+	fail "run past main"
+    }
+    timeout {
+	fail "run past main (timeout)"
+    }
+}
+
+set message "backtrace shows the outer function"
+gdb_test_multiple "backtrace 10" $message {
+    -re "#1\[ \t]*$hex in inner.*$gdb_prompt $" {
+	fail $message
+    }
+    -re "#1\[ \t]*$hex in main.*$gdb_prompt $" {
+	pass $message
+    }
+}


--- NEW FILE gdb-orphanripper.c ---
/*
 * Copyright 2006 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.
 *
 * Reap any leftover children possibly holding file descriptors.
 * 2006-11-30  Jan Kratochvil  <jan.kratochvil at redhat.com>
 */


#define _XOPEN_SOURCE 1
#define _XOPEN_SOURCE_EXTENDED 1
#define _BSD_SOURCE 1

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <dirent.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <fcntl.h>


static const char *progname;

static int spawn (char **argv, pid_t *child_pointer)
{
	pid_t child, child_got;
	int status;

	switch (child = fork ()) {
	case -1:
		perror ("fork(2)");
		exit (EXIT_FAILURE);
	case 0:
		/* Do not setpgrp(2) in the parent process as the process-group
		   is shared for the whole sh(1) pipeline we could be a part
		   of.  The process-group is set according to PID of the first
		   command in the pipeline.
		   We would rip even vi(1) in the case of:
		   	./orphanripper sh -c 'sleep 1&' | vi -
		   */
		if (setpgrp ()) {
			perror ("setpgrp");
			exit (EXIT_FAILURE);
		}
		execvp (argv[1], argv + 1);
		perror ("execvp(2)");
		exit (EXIT_FAILURE);
	default:
		break;
	}
	if (child != (child_got = waitpid (child, &status, 0))) {
		fprintf (stderr, "waitpid(%d)=%d: %m\n", (int) child,
			 (int) child_got);
		exit (EXIT_FAILURE);
	}
	if (!WIFEXITED (status)) {
		fprintf (stderr, "waitpid(2): !WIFEXITED(%d)\n", status);
		exit (EXIT_FAILURE);
	}

	if (child_pointer)
		*child_pointer = child;
	return WEXITSTATUS (status);
}

/* Detected commandline may look weird due to a race:
   Original command:
   	./orphanripper sh -c 'sleep 1&' &
   Correct output:
   	[1] 29610
   	./orphanripper: Killed -9 orphan PID 29612 (PGID 29611): sleep 1
   Raced output (sh(1) child still did not update its argv[]):
   	[1] 29613
   	./orphanripper: Killed -9 orphan PID 29615 (PGID 29614): sh -c sleep 1&
   We could delay a bit before ripping the children.  */
static const char *read_cmdline (pid_t pid)
{
	char cmdline_fname[32];
	static char cmdline[LINE_MAX];
	int fd;
	ssize_t got;
	char *s;

	if (snprintf (cmdline_fname, sizeof (cmdline_fname), "/proc/%d/cmdline",
		  (int) pid) < 0)
		return NULL;
	fd = open (cmdline_fname, O_RDONLY);
	if (fd == -1) {
		fprintf (stderr, "%s: open (\"%s\"): %m\n", progname,
			 cmdline_fname);
		return NULL;
	}
	got = read (fd, cmdline, sizeof (cmdline) - 1);
	if (got == -1)
		fprintf (stderr, "%s: read (\"%s\"): %m\n", progname,
			 cmdline_fname);
	if (close (fd))
		fprintf (stderr, "%s: close (\"%s\"): %m\n", progname,
			 cmdline_fname);
	if (got < 0)
		return NULL;
	/* Convert '\0' argument delimiters to spaces.  */
	for (s = cmdline; s < cmdline + got; s++)
		if (!*s)
			*s = ' ';
	/* Trim the trailing spaces (typically single '\0'->' ').  */
	while (s > cmdline && isspace (s[-1]))
		s--;
	*s = 0;
	return cmdline;
}

static void rip_pid (pid_t pid, pid_t pgid_child)
{
	pid_t pgid_pids;
	const char *cmdline;

	/* Don't shoot ourselves.  */
	if (pid == getpid())
		return;
	pgid_pids = getpgid (pid);
	/* Ignore errors (permissions? untested).  */
	if (pgid_pids == -1)
		return;
	/* Not a process of ours.  */
	if (pgid_pids != pgid_child)
		return;

	cmdline = read_cmdline (pid);
	if (!cmdline)
		cmdline = "<error>";
	fprintf (stderr, "%s: Killed -9 orphan PID %d (PGID %d): %s\n",
	         progname, (int) pid, (int) pgid_pids, cmdline);
	if (kill (pid, SIGKILL)) {
		fprintf (stderr, "%s: kill (%d, SIGKILL): %m\n", progname,
			 (int) pid);
		return;
	}
	/* Do not waitpid(2) as it cannot be our direct descendant and it gets
	   cleaned up by init(8).  */
#if 0
	pid_t pid_got;
	if (pid != (pid_got = waitpid (pid, NULL, 0))) {
		fprintf (stderr, "%s: waitpid (%d) != %d: %m\n", progname,
			 (int) pid, (int) pid_got);
		return;
	}
#endif
}

static void rip (pid_t pgid_child)
{
	DIR *dir;
	struct dirent *dirent;

	dir = opendir ("/proc");
	if (!dir) {
		perror ("opendir (\"/proc\")");
		exit (EXIT_FAILURE);
	}
	while ((errno = 0, dirent = readdir (dir))) {
		const char *cs;

		/* FIXME: POSIX portability.  */
		if (dirent->d_type != DT_DIR)
			continue;
		/* Check /^\d+$/:  */
		for (cs = dirent->d_name; *cs; cs++)
			if (!isdigit (*cs))
				break;
		if (cs == dirent->d_name || *cs)
			continue;
		rip_pid (atoi (dirent->d_name), pgid_child);
	}
	if (errno) {
		perror ("readdir (\"/proc\")");
		exit (EXIT_FAILURE);
	}
	if (closedir (dir)) {
		perror ("closedir (\"/proc\")");
		exit (EXIT_FAILURE);
	}

}

int main (int argc, char **argv)
{
	int rc;
	pid_t child;

	if (argc < 2
	    || !strcmp (argv[1], "-h")
	    || !strcmp (argv[1], "--help")) {
		fputs("Syntax: orphanripper <execvp(3) commandline>\n", stdout);
		exit (EXIT_FAILURE);
	}
	progname = argv[0];
	rc = spawn (argv, &child);
	rip (child);
	return rc;
}


Index: gdb.spec
===================================================================
RCS file: /cvs/dist/rpms/gdb/FC-6/gdb.spec,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -r1.202 -r1.203
--- gdb.spec	14 Oct 2006 23:34:35 -0000	1.202
+++ gdb.spec	11 Dec 2006 21:45:38 -0000	1.203
@@ -11,7 +11,7 @@
 Version: 6.5
 
 # The release always contains a leading reserved number, start it at 0.
-Release: 13%{?dist}
+Release: 14%{?dist}
 
 License: GPL
 Group: Development/Debuggers
@@ -47,6 +47,9 @@
 Patch3: gdb-6.3-rh-testlibunwind-20041202.patch
 Patch4: gdb-6.3-rh-testlibunwind1fix-20041202.patch
 
+# Cleanup any leftover testsuite processes as it may stuck mock(1) builds.
+Source2: gdb-orphanripper.c
+
 
 # ------------------------------------------
 
@@ -285,6 +288,21 @@
 
 # Fix deadlock accessing last address space byte; for corrupted backtraces.
 Patch203: gdb-6.5-last-address-space-byte.patch
+Patch211: gdb-6.5-last-address-space-byte-test.patch
+
+# Fix "??" resolving of symbols from (non-prelinked) debuginfo packages.
+# "gdb-6.5-matching_bfd_sections.patch" is a prerequisited CVS backport.
+Patch205: gdb-6.5-matching_bfd_sections.patch
+Patch206: gdb-6.5-relativedebug.patch
+
+# Fix "??" resolving of symbols from overlapping functions (nanosleep(3)).
+Patch207: gdb-6.5-symbols-overlap.patch
+
+# Improved testsuite results by the testsuite provided by the courtesy of BEA.
+Patch208: gdb-6.5-BEA-testsuite.patch
+
+# Fix readline segfault on excessively long hand-typed lines.
+Patch209: gdb-6.5-readline-long-line-crash.patch
 
 BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext
 BuildRequires: flex bison sharutils
@@ -399,6 +417,12 @@
 %patch200 -p1
 %patch201 -p1
 %patch203 -p1
+%patch205 -p1
+%patch206 -p1
+%patch207 -p1
+%patch208 -p1
+%patch209 -p1
+%patch211 -p1
 
 # Change the version that gets printed at GDB startup, so it is RedHat
 # specific.
@@ -474,9 +498,11 @@
 %ifarch %{ix86} x86_64 s390x s390 ppc ia64 ppc64
 echo ====================TESTING=========================
 cd gdb/testsuite
+gcc -o ./orphanripper %{SOURCE2} -Wall
 # Need to use a single --ignore option, second use overrides first.
 # "chng-syms.exp" for possibly avoiding Linux kernel crash - Bug 207002.
-make -k check RUNTESTFLAGS='--ignore "bigcore.exp chng-syms.exp"' || :
+# "threadcrash.exp" is incompatible on ia64 with old kernels.
+./orphanripper make -k check RUNTESTFLAGS='--ignore "bigcore.exp chng-syms.exp checkpoint.exp threadcrash.exp"' || :
 for t in sum log; do
   ln gdb.$t gdb-%{_target_platform}.$t || :
 done
@@ -560,6 +586,15 @@
 # don't include the files in include, they are part of binutils
 
 %changelog
+* Mon Dec 11 2006 Jan Kratochvil <jan.kratochvil at redhat.com> - 6.5-14
+- Fix "??" resolving of symbols from (non-prelinked) debuginfo packages.
+- Fix "??" resolving of symbols from overlapping functions (nanosleep(3)).
+- Also disable testcase "checkpoint.exp" for a possible kernel Bug 207002.
+- Provided (disabled during build) threading testsuite from BEA.
+- Fix readline segfault on excessively long hand-typed lines.
+- Provide testcase for accessing the last address space byte.
+- Cleanup any leftover testsuite processes as it may stuck mock(1) builds.
+
 * Sat Oct 14 2006 Jan Kratochvil <jan.kratochvil at redhat.com> - 6.5-13
 - Fix deadlock accessing last address space byte; for corrupted backtraces.
 




More information about the fedora-cvs-commits mailing list