Blob Blame History Raw
diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.c
--- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c	2007-12-19 15:12:55.000000000 -0500
+++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.c	2007-12-19 13:55:22.000000000 -0500
@@ -0,0 +1,29 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   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  */
+
+#include <unistd.h>
+
+int main()
+{
+  for (;;)
+    alarm (0);
+  return 0;
+}
diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp
--- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp	2007-12-19 15:12:53.000000000 -0500
+++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp	2007-12-19 15:11:35.000000000 -0500
@@ -0,0 +1,83 @@
+# 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.  
+
+set testfile unwind-leak
+set srcfile ${testfile}.c
+set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
+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}
+
+set pid [exp_pid -i [board_info host fileid]]
+
+# For C programs, "start" should stop in main().
+
+gdb_test "start" \
+         "main \\(\\) at .*$srcfile.*" \
+         "start"
+
+set loc [gdb_get_line_number "alarm"]
+gdb_breakpoint $loc
+
+proc memory_get {} {
+    global pid
+    set fd [open "/proc/$pid/statm"]
+    gets $fd line
+    close $fd
+    # number of pages of data/stack
+    scan $line "%*d%*d%*d%*d%*d%d" drs
+    return $drs
+}
+
+set cycles 100
+# For 100 cycles it was 1308: from = 363 KB, to = 1671 KB
+set permit_kb 100
+verbose -log "cycles = $cycles, permit_kb = $permit_kb"
+
+set fail 0
+set test "breakpoint stop/continue cycles" 
+for {set i $cycles} {$i > 0} {set i [expr {$i - 1}]} {
+    gdb_test_multiple "continue" $test {
+	-re "Breakpoint 2, main .*alarm .*.*${gdb_prompt} $" {
+	}
+	-re "Segmentation fault" {
+	    fail $test
+	    set i 0
+	    set fail 1
+	}
+    }
+    if ![info exists from] {
+	set from [memory_get]
+    }
+}
+set to [memory_get]
+if {!$fail} {
+    verbose -log "from = $from KB, to = $to KB"
+    if {$from > 0 && $to > 10 && $to < $from + $permit_kb} {
+	pass $test
+    } else {
+	fail $test
+    }
+}