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

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