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

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