2017-12-10 22:00:49 +00:00
|
|
|
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
2017-12-04 19:24:00 +00:00
|
|
|
From: Fedora GDB patches <invalid@email.com>
|
|
|
|
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
|
Subject: gdb-6.5-gcore-buffer-limit-test.patch
|
|
|
|
|
|
|
|
FileName: gdb-6.5-gcore-buffer-limit-test.patch
|
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
;; Test gcore memory and time requirements for large inferiors.
|
|
|
|
;;=fedoratest
|
|
|
|
---
|
|
|
|
gdb/testsuite/gdb.base/gcore-excessive-memory.c | 37 +++++++++
|
|
|
|
gdb/testsuite/gdb.base/gcore-excessive-memory.exp | 94 +++++++++++++++++++++++
|
|
|
|
2 files changed, 131 insertions(+)
|
|
|
|
create mode 100644 gdb/testsuite/gdb.base/gcore-excessive-memory.c
|
|
|
|
create mode 100644 gdb/testsuite/gdb.base/gcore-excessive-memory.exp
|
2017-12-04 19:24:00 +00:00
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.c b/gdb/testsuite/gdb.base/gcore-excessive-memory.c
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000000..56b4d3a63a
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.c
|
2008-01-10 17:17:49 +00:00
|
|
|
@@ -0,0 +1,37 @@
|
|
|
|
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
|
+
|
|
|
|
+ Copyright 2008 Free Software Foundation, Inc.
|
|
|
|
+
|
|
|
|
+ This program is free software; you can redistribute it and/or modify
|
|
|
|
+ it under the terms of the GNU General Public License as published by
|
|
|
|
+ the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+ (at your option) any later version.
|
|
|
|
+
|
|
|
|
+ This program is distributed in the hope that it will be useful,
|
|
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+ GNU General Public License for more details.
|
|
|
|
+
|
|
|
|
+ You should have received a copy of the GNU General Public License
|
|
|
|
+ along with this program; if not, write to the Free Software
|
|
|
|
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
+
|
|
|
|
+ Please email any bugs, comments, and/or additions to this file to:
|
|
|
|
+ bug-gdb@prep.ai.mit.edu */
|
|
|
|
+
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+
|
|
|
|
+#define MEGS 64
|
|
|
|
+
|
|
|
|
+int main()
|
|
|
|
+{
|
|
|
|
+ void *mem;
|
|
|
|
+
|
|
|
|
+ mem = malloc (MEGS * 1024ULL * 1024ULL);
|
|
|
|
+
|
|
|
|
+ for (;;)
|
|
|
|
+ sleep (1);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.exp b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000000..4e71b5534e
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
|
2010-07-21 21:30:20 +00:00
|
|
|
@@ -0,0 +1,94 @@
|
2008-01-10 17:17:49 +00:00
|
|
|
+# Copyright 2008 Free Software Foundation, Inc.
|
|
|
|
+
|
|
|
|
+# This program is free software; you can redistribute it and/or modify
|
|
|
|
+# it under the terms of the GNU General Public License as published by
|
|
|
|
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+# (at your option) any later version.
|
|
|
|
+#
|
|
|
|
+# This program is distributed in the hope that it will be useful,
|
|
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+# GNU General Public License for more details.
|
|
|
|
+#
|
|
|
|
+# You should have received a copy of the GNU General Public License
|
|
|
|
+# along with this program; if not, write to the Free Software
|
|
|
|
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
+
|
|
|
|
+set testfile gcore-excessive-memory
|
|
|
|
+set srcfile ${testfile}.c
|
2016-02-16 09:54:56 +00:00
|
|
|
+set shfile [standard_output_file ${testfile}-gdb.sh]
|
|
|
|
+set corefile [standard_output_file ${testfile}.core]
|
|
|
|
+set binfile [standard_output_file ${testfile}]
|
2008-01-10 17:17:49 +00:00
|
|
|
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
|
|
|
+ untested "Couldn't compile test program"
|
|
|
|
+ return -1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+set f [open "|getconf PAGESIZE" "r"]
|
|
|
|
+gets $f pagesize
|
|
|
|
+close $f
|
|
|
|
+
|
|
|
|
+set pid_of_bin [eval exec $binfile &]
|
|
|
|
+sleep 2
|
|
|
|
+
|
|
|
|
+# Get things started.
|
|
|
|
+
|
|
|
|
+gdb_exit
|
|
|
|
+gdb_start
|
|
|
|
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
+gdb_load ${binfile}
|
|
|
|
+
|
|
|
|
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
|
|
|
|
+
|
|
|
|
+gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
|
|
|
|
+gdb_test "up 99" "in main .*" "verify we can get to main"
|
|
|
|
+
|
|
|
|
+proc memory_v_pages_get {} {
|
|
|
|
+ global pid_of_gdb pagesize
|
|
|
|
+ set fd [open "/proc/$pid_of_gdb/statm"]
|
|
|
|
+ gets $fd line
|
|
|
|
+ close $fd
|
|
|
|
+ # number of pages of virtual memory
|
|
|
|
+ scan $line "%d" drs
|
|
|
|
+ return $drs
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+set pages_found [memory_v_pages_get]
|
|
|
|
+
|
|
|
|
+# It must be definitely less than `MEGS' of `gcore-excessive-memory.c'.
|
|
|
|
+set mb_gcore_reserve 4
|
|
|
|
+verbose -log "pages_found = $pages_found, mb_gcore_reserve = $mb_gcore_reserve"
|
|
|
|
+set kb_found [expr $pages_found * $pagesize / 1024]
|
|
|
|
+set kb_permit [expr $kb_found + 1 * 1024 + $mb_gcore_reserve * 1024]
|
|
|
|
+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
|
|
|
|
+
|
|
|
|
+# Create the ulimit wrapper.
|
|
|
|
+set f [open $shfile "w"]
|
|
|
|
+puts $f "#! /bin/sh"
|
|
|
|
+puts $f "ulimit -v $kb_permit"
|
|
|
|
+puts $f "exec $GDB \"\$@\""
|
|
|
|
+close $f
|
|
|
|
+remote_exec host "chmod +x $shfile"
|
|
|
|
+
|
|
|
|
+gdb_exit
|
|
|
|
+set GDBold $GDB
|
|
|
|
+set GDB "$shfile"
|
|
|
|
+gdb_start
|
|
|
|
+set GDB $GDBold
|
|
|
|
+
|
|
|
|
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
+gdb_load ${binfile}
|
|
|
|
+
|
|
|
|
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
|
|
|
|
+
|
|
|
|
+gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
|
|
|
|
+gdb_test "up 99" "in main .*" "verify we can get to main"
|
|
|
|
+
|
|
|
|
+verbose -log "kb_found before gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
|
|
|
|
+
|
|
|
|
+gdb_test "gcore $corefile" "Saved corefile \[^\n\r\]*" "Save the core file"
|
|
|
|
+
|
|
|
|
+verbose -log "kb_found after gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
|
2008-01-12 16:16:46 +00:00
|
|
|
+
|
|
|
|
+# Cleanup.
|
|
|
|
+exec kill -9 $pid_of_bin
|
2017-12-08 04:31:26 +00:00
|
|
|
--
|
|
|
|
2.14.3
|
|
|
|
|