|
|
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-gcore-buffer-limit-test.patch
|
|
|
ed07ac |
|
|
|
ed07ac |
;; Test gcore memory and time requirements for large inferiors.
|
|
|
ed07ac |
;;=fedoratest
|
|
|
ed07ac |
|
|
|
ed07ac |
diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.c b/gdb/testsuite/gdb.base/gcore-excessive-memory.c
|
|
|
ed07ac |
new file mode 100644
|
|
|
ed07ac |
--- /dev/null
|
|
|
ed07ac |
+++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.c
|
|
|
ed07ac |
@@ -0,0 +1,37 @@
|
|
|
ed07ac |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+ Copyright 2008 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 |
+#include <stdlib.h>
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+#define MEGS 64
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+int main()
|
|
|
ed07ac |
+{
|
|
|
ed07ac |
+ void *mem;
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+ mem = malloc (MEGS * 1024ULL * 1024ULL);
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+ for (;;)
|
|
|
ed07ac |
+ sleep (1);
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+ return 0;
|
|
|
ed07ac |
+}
|
|
|
ed07ac |
diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.exp b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
|
|
|
ed07ac |
new file mode 100644
|
|
|
ed07ac |
--- /dev/null
|
|
|
ed07ac |
+++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
|
|
|
ed07ac |
@@ -0,0 +1,99 @@
|
|
|
ed07ac |
+# Copyright 2008 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 gcore-excessive-memory
|
|
|
ed07ac |
+set srcfile ${testfile}.c
|
|
|
ed07ac |
+set shfile [standard_output_file ${testfile}-gdb.sh]
|
|
|
ed07ac |
+set corefile [standard_output_file ${testfile}.core]
|
|
|
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 |
+set f [open "|getconf PAGESIZE" "r"]
|
|
|
ed07ac |
+gets $f pagesize
|
|
|
ed07ac |
+close $f
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+set pid_of_bin [eval exec $binfile &]
|
|
|
ed07ac |
+sleep 2
|
|
|
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_of_gdb [exp_pid -i [board_info host fileid]]
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
|
|
|
ed07ac |
+gdb_test "up 99" "in main .*" "verify we can get to main"
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+proc memory_v_pages_get {} {
|
|
|
ed07ac |
+ global pid_of_gdb pagesize
|
|
|
ed07ac |
+ set fd [open "/proc/$pid_of_gdb/statm"]
|
|
|
ed07ac |
+ gets $fd line
|
|
|
ed07ac |
+ close $fd
|
|
|
ed07ac |
+ # number of pages of virtual memory
|
|
|
ed07ac |
+ scan $line "%d" drs
|
|
|
ed07ac |
+ return $drs
|
|
|
ed07ac |
+}
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+set pages_found [memory_v_pages_get]
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+# It must be definitely less than `MEGS' of `gcore-excessive-memory.c'.
|
|
|
ed07ac |
+set mb_gcore_reserve 4
|
|
|
ed07ac |
+verbose -log "pages_found = $pages_found, mb_gcore_reserve = $mb_gcore_reserve"
|
|
|
ed07ac |
+set kb_found [expr $pages_found * $pagesize / 1024]
|
|
|
ed07ac |
+set kb_permit [expr $kb_found + 1 * 1024 + $mb_gcore_reserve * 1024]
|
|
|
ed07ac |
+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+# Create the ulimit wrapper.
|
|
|
ed07ac |
+set f [open $shfile "w"]
|
|
|
ed07ac |
+puts $f "#! /bin/sh"
|
|
|
ed07ac |
+puts $f "ulimit -v $kb_permit"
|
|
|
ed07ac |
+puts $f "exec $GDB \"\$@\""
|
|
|
ed07ac |
+close $f
|
|
|
ed07ac |
+remote_exec host "chmod +x $shfile"
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+gdb_exit
|
|
|
ed07ac |
+set GDBold $GDB
|
|
|
ed07ac |
+set GDB "$shfile"
|
|
|
ed07ac |
+gdb_start
|
|
|
ed07ac |
+set GDB $GDBold
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
ed07ac |
+gdb_load ${binfile}
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
|
|
|
ed07ac |
+gdb_test "up 99" "in main .*" "verify we can get to main"
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+verbose -log "kb_found before gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+gdb_test "gcore $corefile" "Saved corefile \[^\n\r\]*" "Save the core file"
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+verbose -log "kb_found after gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
|
|
|
ed07ac |
+
|
|
|
ed07ac |
+# Cleanup.
|
|
|
ed07ac |
+exec kill -9 $pid_of_bin
|