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

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