22d1e60
Index: gdb-7.10.90.20160211/gdb/testsuite/gdb.base/unwind-leak.c
22d1e60
===================================================================
22d1e60
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
22d1e60
+++ gdb-7.10.90.20160211/gdb/testsuite/gdb.base/unwind-leak.c	2016-02-15 23:32:11.307402446 +0100
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
+}
22d1e60
Index: gdb-7.10.90.20160211/gdb/testsuite/gdb.base/unwind-leak.exp
22d1e60
===================================================================
22d1e60
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
22d1e60
+++ gdb-7.10.90.20160211/gdb/testsuite/gdb.base/unwind-leak.exp	2016-02-15 23:32:18.559453937 +0100
dd46ae6
@@ -0,0 +1,83 @@
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
+set testfile unwind-leak
3f52bbd
+set srcfile ${testfile}.c
22d1e60
+set shfile [standard_output_file ${testfile}-gdb.sh]
22d1e60
+set binfile [standard_output_file ${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
+}