Blame SOURCES/gdb-6.5-ia64-libunwind-leak-test.patch

132741
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
132741
From: Fedora GDB patches <invalid@email.com>
132741
Date: Fri, 27 Oct 2017 21:07:50 +0200
132741
Subject: gdb-6.5-ia64-libunwind-leak-test.patch
132741
132741
;; Test ia64 memory leaks of the code using libunwind.
132741
;;=fedoratest
132741
132741
diff --git a/gdb/testsuite/gdb.base/unwind-leak.c b/gdb/testsuite/gdb.base/unwind-leak.c
132741
new file mode 100644
132741
--- /dev/null
132741
+++ b/gdb/testsuite/gdb.base/unwind-leak.c
132741
@@ -0,0 +1,29 @@
132741
+/* This testcase is part of GDB, the GNU debugger.
132741
+
132741
+   Copyright 2007 Free Software Foundation, Inc.
132741
+
132741
+   This program is free software; you can redistribute it and/or modify
132741
+   it under the terms of the GNU General Public License as published by
132741
+   the Free Software Foundation; either version 2 of the License, or
132741
+   (at your option) any later version.
132741
+
132741
+   This program is distributed in the hope that it will be useful,
132741
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
132741
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132741
+   GNU General Public License for more details.
132741
+
132741
+   You should have received a copy of the GNU General Public License
132741
+   along with this program; if not, write to the Free Software
132741
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
132741
+
132741
+   Please email any bugs, comments, and/or additions to this file to:
132741
+   bug-gdb@prep.ai.mit.edu  */
132741
+
132741
+#include <unistd.h>
132741
+
132741
+int main()
132741
+{
132741
+  for (;;)
132741
+    alarm (0);
132741
+  return 0;
132741
+}
132741
diff --git a/gdb/testsuite/gdb.base/unwind-leak.exp b/gdb/testsuite/gdb.base/unwind-leak.exp
132741
new file mode 100644
132741
--- /dev/null
132741
+++ b/gdb/testsuite/gdb.base/unwind-leak.exp
132741
@@ -0,0 +1,88 @@
132741
+# Copyright 2007 Free Software Foundation, Inc.
132741
+
132741
+# This program is free software; you can redistribute it and/or modify
132741
+# it under the terms of the GNU General Public License as published by
132741
+# the Free Software Foundation; either version 2 of the License, or
132741
+# (at your option) any later version.
132741
+#
132741
+# This program is distributed in the hope that it will be useful,
132741
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
132741
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132741
+# GNU General Public License for more details.
132741
+#
132741
+# You should have received a copy of the GNU General Public License
132741
+# along with this program; if not, write to the Free Software
132741
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
132741
+
132741
+if {[use_gdb_stub]} {
132741
+    untested "skipping test because of use_gdb_stub"
132741
+    return -1
132741
+}
132741
+
132741
+set testfile unwind-leak
132741
+set srcfile ${testfile}.c
132741
+set shfile [standard_output_file ${testfile}-gdb.sh]
132741
+set binfile [standard_output_file ${testfile}]
132741
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
132741
+    untested "Couldn't compile test program"
132741
+    return -1
132741
+}
132741
+
132741
+# Get things started.
132741
+
132741
+gdb_exit
132741
+gdb_start
132741
+gdb_reinitialize_dir $srcdir/$subdir
132741
+gdb_load ${binfile}
132741
+
132741
+set pid [exp_pid -i [board_info host fileid]]
132741
+
132741
+# For C programs, "start" should stop in main().
132741
+
132741
+gdb_test "start" \
132741
+         "main \\(\\) at .*$srcfile.*" \
132741
+         "start"
132741
+
132741
+set loc [gdb_get_line_number "alarm"]
132741
+gdb_breakpoint $loc
132741
+
132741
+proc memory_get {} {
132741
+    global pid
132741
+    set fd [open "/proc/$pid/statm"]
132741
+    gets $fd line
132741
+    close $fd
132741
+    # number of pages of data/stack
132741
+    scan $line "%*d%*d%*d%*d%*d%d" drs
132741
+    return $drs
132741
+}
132741
+
132741
+set cycles 100
132741
+# For 100 cycles it was 1308: from = 363 KB, to = 1671 KB
132741
+set permit_kb 100
132741
+verbose -log "cycles = $cycles, permit_kb = $permit_kb"
132741
+
132741
+set fail 0
132741
+set test "breakpoint stop/continue cycles"
132741
+for {set i $cycles} {$i > 0} {set i [expr {$i - 1}]} {
132741
+    gdb_test_multiple "continue" $test {
132741
+	-re "Breakpoint 2, main .*alarm .*.*${gdb_prompt} $" {
132741
+	}
132741
+	-re "Segmentation fault" {
132741
+	    fail $test
132741
+	    set i 0
132741
+	    set fail 1
132741
+	}
132741
+    }
132741
+    if ![info exists from] {
132741
+	set from [memory_get]
132741
+    }
132741
+}
132741
+set to [memory_get]
132741
+if {!$fail} {
132741
+    verbose -log "from = $from KB, to = $to KB"
132741
+    if {$from > 0 && $to > 10 && $to < $from + $permit_kb} {
132741
+	pass $test
132741
+    } else {
132741
+	fail $test
132741
+    }
132741
+}