Blame SOURCES/gdb-6.5-gcore-buffer-limit-test.patch

f9426a
diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.c gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.c
f9426a
--- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.c	1970-01-01 01:00:00.000000000 +0100
f9426a
+++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.c	2008-01-08 11:25:45.000000000 +0100
f9426a
@@ -0,0 +1,37 @@
f9426a
+/* This testcase is part of GDB, the GNU debugger.
f9426a
+
f9426a
+   Copyright 2008 Free Software Foundation, Inc.
f9426a
+
f9426a
+   This program is free software; you can redistribute it and/or modify
f9426a
+   it under the terms of the GNU General Public License as published by
f9426a
+   the Free Software Foundation; either version 2 of the License, or
f9426a
+   (at your option) any later version.
f9426a
+
f9426a
+   This program is distributed in the hope that it will be useful,
f9426a
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
f9426a
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9426a
+   GNU General Public License for more details.
f9426a
+ 
f9426a
+   You should have received a copy of the GNU General Public License
f9426a
+   along with this program; if not, write to the Free Software
f9426a
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
f9426a
+
f9426a
+   Please email any bugs, comments, and/or additions to this file to:
f9426a
+   bug-gdb@prep.ai.mit.edu  */
f9426a
+
f9426a
+#include <unistd.h>
f9426a
+#include <stdlib.h>
f9426a
+
f9426a
+#define MEGS 64
f9426a
+
f9426a
+int main()
f9426a
+{
f9426a
+  void *mem;
f9426a
+  
f9426a
+  mem = malloc (MEGS * 1024ULL * 1024ULL);
f9426a
+
f9426a
+  for (;;)
f9426a
+    sleep (1);
f9426a
+
f9426a
+  return 0;
f9426a
+}
f9426a
diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
f9426a
--- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp	1970-01-01 01:00:00.000000000 +0100
f9426a
+++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp	2008-01-08 11:47:32.000000000 +0100
f9426a
@@ -0,0 +1,94 @@
f9426a
+# Copyright 2008 Free Software Foundation, Inc.
f9426a
+
f9426a
+# This program is free software; you can redistribute it and/or modify
f9426a
+# it under the terms of the GNU General Public License as published by
f9426a
+# the Free Software Foundation; either version 2 of the License, or
f9426a
+# (at your option) any later version.
f9426a
+# 
f9426a
+# This program is distributed in the hope that it will be useful,
f9426a
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f9426a
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9426a
+# GNU General Public License for more details.
f9426a
+# 
f9426a
+# You should have received a copy of the GNU General Public License
f9426a
+# along with this program; if not, write to the Free Software
f9426a
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
f9426a
+
f9426a
+set testfile gcore-excessive-memory
f9426a
+set srcfile ${testfile}.c
f9426a
+set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
f9426a
+set corefile ${objdir}/${subdir}/${testfile}.core
f9426a
+set binfile ${objdir}/${subdir}/${testfile}
f9426a
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
f9426a
+    untested "Couldn't compile test program"
f9426a
+    return -1
f9426a
+}
f9426a
+
f9426a
+set f [open "|getconf PAGESIZE" "r"]
f9426a
+gets $f pagesize
f9426a
+close $f
f9426a
+
f9426a
+set pid_of_bin [eval exec $binfile &]
f9426a
+sleep 2
f9426a
+
f9426a
+# Get things started.
f9426a
+
f9426a
+gdb_exit
f9426a
+gdb_start
f9426a
+gdb_reinitialize_dir $srcdir/$subdir
f9426a
+gdb_load ${binfile}
f9426a
+
f9426a
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
f9426a
+
f9426a
+gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
f9426a
+gdb_test "up 99" "in main .*" "verify we can get to main"
f9426a
+
f9426a
+proc memory_v_pages_get {} {
f9426a
+    global pid_of_gdb pagesize
f9426a
+    set fd [open "/proc/$pid_of_gdb/statm"]
f9426a
+    gets $fd line
f9426a
+    close $fd
f9426a
+    # number of pages of virtual memory
f9426a
+    scan $line "%d" drs
f9426a
+    return $drs
f9426a
+}
f9426a
+
f9426a
+set pages_found [memory_v_pages_get]
f9426a
+
f9426a
+# It must be definitely less than `MEGS' of `gcore-excessive-memory.c'.
f9426a
+set mb_gcore_reserve 4
f9426a
+verbose -log "pages_found = $pages_found, mb_gcore_reserve = $mb_gcore_reserve"
f9426a
+set kb_found [expr $pages_found * $pagesize / 1024]
f9426a
+set kb_permit [expr $kb_found + 1 * 1024 + $mb_gcore_reserve * 1024]
f9426a
+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
f9426a
+
f9426a
+# Create the ulimit wrapper.
f9426a
+set f [open $shfile "w"]
f9426a
+puts $f "#! /bin/sh"
f9426a
+puts $f "ulimit -v $kb_permit"
f9426a
+puts $f "exec $GDB \"\$@\""
f9426a
+close $f
f9426a
+remote_exec host "chmod +x $shfile"
f9426a
+
f9426a
+gdb_exit
f9426a
+set GDBold $GDB
f9426a
+set GDB "$shfile"
f9426a
+gdb_start
f9426a
+set GDB $GDBold
f9426a
+
f9426a
+gdb_reinitialize_dir $srcdir/$subdir
f9426a
+gdb_load ${binfile}
f9426a
+
f9426a
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
f9426a
+
f9426a
+gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
f9426a
+gdb_test "up 99" "in main .*" "verify we can get to main"
f9426a
+
f9426a
+verbose -log "kb_found before gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
f9426a
+
f9426a
+gdb_test "gcore $corefile" "Saved corefile \[^\n\r\]*" "Save the core file"
f9426a
+
f9426a
+verbose -log "kb_found after gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
f9426a
+
f9426a
+# Cleanup.
f9426a
+exec kill -9 $pid_of_bin