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

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