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