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

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