3f52bbd
diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.c
3f52bbd
--- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c	2007-12-19 15:12:55.000000000 -0500
3f52bbd
+++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.c	2007-12-19 13:55:22.000000000 -0500
3f52bbd
@@ -0,0 +1,29 @@
3f52bbd
+/* This testcase is part of GDB, the GNU debugger.
3f52bbd
+
3f52bbd
+   Copyright 2007 Free Software Foundation, Inc.
3f52bbd
+
3f52bbd
+   This program is free software; you can redistribute it and/or modify
3f52bbd
+   it under the terms of the GNU General Public License as published by
3f52bbd
+   the Free Software Foundation; either version 2 of the License, or
3f52bbd
+   (at your option) any later version.
3f52bbd
+
3f52bbd
+   This program is distributed in the hope that it will be useful,
3f52bbd
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
3f52bbd
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3f52bbd
+   GNU General Public License for more details.
3f52bbd
+ 
3f52bbd
+   You should have received a copy of the GNU General Public License
3f52bbd
+   along with this program; if not, write to the Free Software
3f52bbd
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3f52bbd
+
3f52bbd
+   Please email any bugs, comments, and/or additions to this file to:
3f52bbd
+   bug-gdb@prep.ai.mit.edu  */
3f52bbd
+
3f52bbd
+#include <unistd.h>
3f52bbd
+
3f52bbd
+int main()
3f52bbd
+{
3f52bbd
+  for (;;)
3f52bbd
+    alarm (0);
3f52bbd
+  return 0;
3f52bbd
+}
3f52bbd
diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp
3f52bbd
--- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp	2007-12-19 15:12:53.000000000 -0500
3f52bbd
+++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp	2007-12-19 15:11:35.000000000 -0500
3f52bbd
@@ -0,0 +1,90 @@
3f52bbd
+# Copyright 2007 Free Software Foundation, Inc.
3f52bbd
+
3f52bbd
+# This program is free software; you can redistribute it and/or modify
3f52bbd
+# it under the terms of the GNU General Public License as published by
3f52bbd
+# the Free Software Foundation; either version 2 of the License, or
3f52bbd
+# (at your option) any later version.
3f52bbd
+# 
3f52bbd
+# This program is distributed in the hope that it will be useful,
3f52bbd
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
3f52bbd
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3f52bbd
+# GNU General Public License for more details.
3f52bbd
+# 
3f52bbd
+# You should have received a copy of the GNU General Public License
3f52bbd
+# along with this program; if not, write to the Free Software
3f52bbd
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
3f52bbd
+
3f52bbd
+if $tracelevel then {
3f52bbd
+    strace $tracelevel
3f52bbd
+}
3f52bbd
+
3f52bbd
+set prms_id 0
3f52bbd
+set bug_id 0
3f52bbd
+
3f52bbd
+set testfile unwind-leak
3f52bbd
+set srcfile ${testfile}.c
3f52bbd
+set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
3f52bbd
+set binfile ${objdir}/${subdir}/${testfile}
3f52bbd
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
3f52bbd
+    untested "Couldn't compile test program"
3f52bbd
+    return -1
3f52bbd
+}
3f52bbd
+
3f52bbd
+# Get things started.
3f52bbd
+
3f52bbd
+gdb_exit
3f52bbd
+gdb_start
3f52bbd
+gdb_reinitialize_dir $srcdir/$subdir
3f52bbd
+gdb_load ${binfile}
3f52bbd
+
3f52bbd
+set pid [exp_pid -i [board_info host fileid]]
3f52bbd
+
3f52bbd
+# For C programs, "start" should stop in main().
3f52bbd
+
3f52bbd
+gdb_test "start" \
3f52bbd
+         "main \\(\\) at .*$srcfile.*" \
3f52bbd
+         "start"
3f52bbd
+
3f52bbd
+set loc [gdb_get_line_number "alarm"]
3f52bbd
+gdb_breakpoint $loc
3f52bbd
+
3f52bbd
+proc memory_get {} {
3f52bbd
+    global pid
3f52bbd
+    set fd [open "/proc/$pid/statm"]
3f52bbd
+    gets $fd line
3f52bbd
+    close $fd
3f52bbd
+    # number of pages of data/stack
3f52bbd
+    scan $line "%*d%*d%*d%*d%*d%d" drs
3f52bbd
+    return $drs
3f52bbd
+}
3f52bbd
+
3f52bbd
+set cycles 100
3f52bbd
+# For 100 cycles it was 1308: from = 363 KB, to = 1671 KB
3f52bbd
+set permit_kb 100
3f52bbd
+verbose -log "cycles = $cycles, permit_kb = $permit_kb"
3f52bbd
+
3f52bbd
+set fail 0
3f52bbd
+set test "breakpoint stop/continue cycles" 
3f52bbd
+for {set i $cycles} {$i > 0} {set i [expr {$i - 1}]} {
3f52bbd
+    gdb_test_multiple "continue" $test {
3f52bbd
+	-re "Breakpoint 2, main .*alarm .*.*${gdb_prompt} $" {
3f52bbd
+	}
3f52bbd
+	-re "Segmentation fault" {
3f52bbd
+	    fail $test
3f52bbd
+	    set i 0
3f52bbd
+	    set fail 1
3f52bbd
+	}
3f52bbd
+    }
3f52bbd
+    if ![info exists from] {
3f52bbd
+	set from [memory_get]
3f52bbd
+    }
3f52bbd
+}
3f52bbd
+set to [memory_get]
3f52bbd
+if {!$fail} {
3f52bbd
+    verbose -log "from = $from KB, to = $to KB"
3f52bbd
+    if {$from > 0 && $to > 10 && $to < $from + $permit_kb} {
3f52bbd
+	pass $test
3f52bbd
+    } else {
3f52bbd
+	fail $test
3f52bbd
+    }
3f52bbd
+}