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

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