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

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