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

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